Quantcast
Channel: Topic Tag: action | WordPress.org
Viewing all articles
Browse latest Browse all 889

bcworkz on "AJAX Hook Not Responding"

$
0
0

I looked through your code again and think I see the problem. I don't have a lot of experience using JSON in javascript, but I believe I'm correct here.

You ajax response handler is trying to use the JSON string as an object. You need to parse it from a string to an object before trying to use it as you are. You could simply use eval(), but that has serious security issues. Use something like obj = JSON.parse(response);.

The other thing is you're checking for certain properties which are never created in the JSON response in the first place, such as response.success. For that to work, your PHP response array before encoding needs to be more like this:

array('success' => true,
   'data' => $debugArray,
)

Viewing all articles
Browse latest Browse all 889

Trending Articles