我有那个代码:
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);
Run Code Online (Sandbox Code Playgroud)
知道出了什么问题吗?