如何在jquery模板中检索n个对象数组的数据?
您正在寻找的json应该是这样的如何在jquery模板中检索n个对象数组的数据?,jquery,json,jquery-templates,Jquery,Json,Jquery Templates,您正在寻找的json应该是这样的 var json = [{ "id": "702", "nid": "1", "node_count": "211", "sdata": "100", "stype": "1", "timestamp": "2014-04-04 09:00:42" }][{ "id": "697", "nid": "2", "node_count": "218", "sdata": "0",
var json = [{
"id": "702",
"nid": "1",
"node_count": "211",
"sdata": "100",
"stype": "1",
"timestamp": "2014-04-04 09:00:42"
}][{
"id": "697",
"nid": "2",
"node_count": "218",
"sdata": "0",
"stype": "1",
"timestamp": "2014-04-0 4 08:41:05"
}][{
"id": "700",
"nid": "3",
"node_count": "217",
"sdata": "0",
"stype": "1",
"timestamp": "2014-04-04 08:41:52"
}][{
"id": "699",
"nid": "4",
"node_count": "33",
"sdata": "0",
"stype": "1",
"timestamp": "2014-0 4-04 08:41:46"
}][{
"id": "701",
"nid": "5",
"node_count": "23",
"sdata": "0",
"stype": "1",
"timestamp": "2014-04-04 08:42:20"
}]
$.each(json, function (arrayID, SensorData) {
alert('Node id' + SensorData.nid);
alert('SensorData' + SensorData.sdata);
alert('Sensor Type' + SensorData.stype);
alert('Time is ' + SensorData.timestamp);
});
你的语法完全无效。另外,对这个问题的一些解释以及你试图实现的目标也会有很大帮助。Rory,你能帮我如何检索数据吗?我不是这样得到的。参考我已经测试过的这个链接,那个链接,但我的json数据并没有按照你的建议提供。因为上面的问题我的数据是以那种形式提供的,我想用那个,在不同的表中显示每个
var json = [{
"id": "702",
"nid": "1",
"node_count": "211",
"sdata": "100",
"stype": "1",
"timestamp": "2014-04-04 09:00:42"
},
{
"id": "697",
"nid": "2",
"node_count": "218",
"sdata": "0",
"stype": "1",
"timestamp": "2014-04-0 4 08:41:05"
},
{
"id": "700",
"nid": "3",
"node_count": "217",
"sdata": "0",
"stype": "1",
"timestamp": "2014-04-04 08:41:52"
},
{
"id": "699",
"nid": "4",
"node_count": "33",
"sdata": "0",
"stype": "1",
"timestamp": "2014-0 4-04 08:41:46"
},{
"id": "701",
"nid": "5",
"node_count": "23",
"sdata": "0",
"stype": "1",
"timestamp": "2014-04-04 08:42:20"
}];