0
我的PHP脚本正在返回我在AJAX调用中收到的JSON对象。在AJAX中使用由PHP返回的Json
$arr[0] = $resp;
$arr[1] = $e;
return json_encode($arr);
现在在我的AJAX调用,我试图让价值,但我得到的是"/"
或"'"
。
我正在做这个AJAX。
dd = JSON.stringify(x.responseText); //this is the response from PHP which is correct I have verified.
alert(dd[0]); //supposed to output $arr[0] but it doesn't
我在这里做错了什么?
'console.log(dd)' –
@u_mulder问题不在于alert或console.log或打印问题,它关于获取正确的数据。 –
Console.log,看看你在dd中有什么。 'JSON.stringify'顺便说一句json字符串。也许你需要'JSON.parse'? –