Reputation: 641
$.ajax({
url: 'contact',
type: 'post',
asynch: 'false',
dataType: 'json' ,
data: "recaptcha_challenge_field=" + $("#recaptcha_challenge_field").val() +
"&recaptcha_response_field=" + $("#recaptcha_response_field").val() ,
success: function(data) {
alert(data);
return;
}
});
json reponse looks like this
{"the_result":"false"}
but alert(data) gives [object,object]
Upvotes: 0
Views: 362
Reputation: 60580
alert(data.the_result)
will display false
in your example, or whatever the value of the_result
is generally.
Upvotes: 11
Reputation: 4793
I think your success function should look like this:
function(data){
alert(data.the_result);
return;
}
Upvotes: 0
Reputation: 2001
try this:
alert(JSON.stringify(data));
then you'll be able to see that data as you want to.
Upvotes: -6
Reputation: 2048
The response that you are getting is an Object. To display the data, you need to use:
alert(data.the_result);
or
alert(data["the_result"]);
If you just want the whole JSON string then just change the dataType to "text".
Upvotes: 4