【问题标题】:How to retrive data for n array of objects in jquery templates? [closed]如何在 jquery 模板中检索 n 个对象数组的数据? [关闭]
【发布时间】:2014-09-09 10:04:01
【问题描述】:
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 你能帮我如何检索数据

标签: jquery json jquery-templates


【解决方案1】:

你要找的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"
}];

【讨论】:

  • 我不会这样
  • 参考此链接jsfiddle.net/KEeyU/1
  • 我已经测试过,那个,但是我的json数据没有按照你的建议来
  • 您到底在寻找什么?
  • 由于上述问题,我的数据来自该表格,我想使用该表格,将每个表格显示在不同的表格中
猜你喜欢
  • 2012-11-16
  • 1970-01-01
  • 2018-12-24
  • 1970-01-01
  • 1970-01-01
  • 2012-07-25
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多