我的要求阿賈克斯與json_encode:解析JSON jQuery的
[{"idHome":"1","Photo":"home-1.jpg","Publier":"1"},
{"idHome":"2","Photo":"home2.jpg","Publier":"1"},
{"idHome":"3","Photo":"home3.jpg","Publier":"1"}]
var string = JSON.stringify(data);
var obj = $.parseJSON(string);
console.log(string);
var idHome = obj.idHome;
var photo = obj.Photo;
console.log(obj.idHome);
console.log(obj.Photo);
問題的解析JSON
控制檯日誌:
[{"idHome":"1","Photo":"home-1.jpg","Publier":"1"},{"idHome":"2","Photo":"home-2.jpg","Publier":"1"},{"idHome":"3","Photo":"home-3.jpg","Publier":"1"}]
undefined
undefined
W¯¯ hy不使用'$ .getJSON'而不是'$ .ajax'? –
我使用$ .ajax! $ .ajax({url:「url」, data:'GET', dataType:'json', – boube
您已編碼數組...'console.log(obj [0]);' –