我从php获取数据。我解析为JSON
var d = $.parseJSON(returnData);
d.designer看起来像:
[Object, Object, Object]
0: Object
_id: 1
family: null
firstname: "XX"
lastname: "YY"
__proto__: Object
1: Object
_id: 2
family: null
firstname: "XX"
lastname: "YY"
__proto__: Object
2: Object
_id: 5
family: null
firstname: "XX"
lastname: "YY"
__proto__: Object
使用jquery如何循环使用对象来获取:
Id: 1
Id: 2
ID: 5
其中ID值是键_id?
答案 0 :(得分:1)
您可以使用每个返回值和每个元素的键
$.each(d, function( index, value ) {
console.log("ID: "+index);
});