Solved

Wordpress Query

Posted on 2016-10-09
1
40 Views
Last Modified: 2016-11-07
I am writing an AJAX call with Wordpress.  I have a simple query and for some reason it is not working.   The result of the following query is "access_registration" and I have written it that way so it always passes.  However, it the Console (Chrome) the JSON I get back is:
Object
Am I running the query correctly?


function checkPassword(){
    global $wpdb;

$return = "";
$return = $_POST['regpass'];

$result = $wpdb->get_results( "SELECT user_login FROM wp_dd6xmx2by0_users WHERE ID = '8'");
if($result == 'access_registration') {
    $return = "GO";
} else {
    $return = 'NO GO';
}
wp_send_json($result);
   
}
add_action('wp_ajax_checkPassword', 'checkPassword');
add_action('wp_ajax_nopriv_checkPassword', 'checkPassword');

Open in new window

0
Comment
Question by:rgranlund
1 Comment
 
LVL 35

Accepted Solution

by:
Terry Woods earned 500 total points
ID: 41836348
Have you based your javascript code on the example in the documentation for wp_send_json? https://codex.wordpress.org/Function_Reference/wp_send_json
0

Featured Post

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction A frequently asked question goes something like this:  "I am running a long process in the background and I want to alert my client when the process finishes.  How can I send a message to the browser?"  Unfortunately, the short answer …
Introduction This article is intended for those who are new to PHP error handling (https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html).  It addresses one of the most common problems that plague beginning PHP develop…
The purpose of this video is to demonstrate how to Import and export files in WordPress. This will be demonstrated using a Windows 8 PC. Go to your WordPress login page. This will look like the following: mywebsite.com/wp-login.php : Click on Too…
The purpose of this video is to demonstrate how to set up an RSS Feed on a WordPress Website. This will be demonstrated using a Windows 8 PC. Feedburner will be used for this demonstration. Go to your WordPress login page. This will look like the…

785 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question