I have that code:
var s, d, p = '';
$.ajax(
{
type: "POST",
url: ajaxurl,
data: {action: "get_info"},
success: function(r)
{
// r contain that json data
// {"s":"long-string","d":"string","p":"string"}
// That served from the server with that header
//
// header('Cache-Control: no-cache, must-revalidate');
// header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
// header('Content-type: application/json');
d = r.d;
s = r.s;
p = r.p;
}
}
);
// And here console return s as undefined
console.log(s);
Any idea on what's going wrong with that ?
console.debug(r)at the first point in the success callback and see what returns.sanddwill be undefined because of the way you've declared them? jsfiddle.net/beneverard/KdDVe