【发布时间】:2014-11-30 16:47:47
【问题描述】:
[
{
"id": 1,
"name": "John",
"age": 11
},
{
"id": 2,
"name": "Maria",
"age": 12
},
[
{
"id": 1,
"store": "market place",
"phone": 1234567890,
"type": "market"
},
{
"id": 2,
"store": "ration",
"phone": 1234567890,
"type": "animal"
}
]
]
我正在尝试获取 store、phone 和 type 值。但我只得到了name 和age。
我有这个:
$.each(data, function (i, x) {
alert(x.phone) // give all null 4x times
});
如何迭代我的所有 json?我试图添加另一个each,但它显示给我undefined
【问题讨论】:
-
试试
$.each(data[2], function(i, x) {... -
查看这个问题/答案:stackoverflow.com/questions/23310353/… 也许了解 JS 对象会有所帮助
-
试试 $.each(data[0][2], function(i, x){.....
标签: jquery