javascript - 将 Json 放入 HTML 表格

标签 javascript jquery html json

您好,我有一个 PHP 脚本,它正在获取信息,然后将其放入一个数组中,这里是 Json 数组的样子

 {
"People": [
    {
        "Person1": {
            "Op": "5459",
            "Name": "Place holder",
            "WorkHours": "5.0",
            "Start": "3:00PM",
            "End": "8:00PM",
            "Clock": false,
            "OFF": false,
            "ON": false,
            "OUT": false
        }
    },
    {
        "Person2": {
            "Op": "5630",
            "Name": "Place holder",
            "WorkHours": "8.75",
            "Start": "7:45AM",
            "End": "4:30PM",
            "Clock": "07:26:49",
            "OFF": false,
            "ON": false,
            "OUT": false
        }
    },
    {
        "Person3": {
            "Op": "5617",
            "Name": "Place holder",
            "WorkHours": "8.5",
            "Start": "7:45AM",
            "End": "4:15PM",
            "Clock": "07:47:06",
            "OFF": "12:00:59",
            "ON": false,
            "OUT": false
        }
    },
    {
        "Person4": {
            "Op": "5596",
            "Name": "Place holder",
            "WorkHours": "5.0",
            "Start": "7:45AM",
            "End": "2:45PM",
            "Clock": "07:46:43",
            "OFF": "12:01:10",
            "ON": false,
            "OUT": false
        }
    },
    {
        "Person5": {
            "Op": "5722",
            "Name": "Place holder",
            "WorkHours": "3.0",
            "Start": "5:00PM",
            "End": "8:00PM",
            "Clock": false,
            "OFF": false,
            "ON": false,
            "OUT": false
        }
    }
]

那么循环遍历这种数组然后将其输出到 html 表格中的最佳方法是什么?

最佳答案

您可以使用 jQuery 函数

getJson:http://api.jquery.com/jquery.getjson/

ajax:http://api.jquery.com/jquery.ajax/

关于javascript - 将 Json 放入 HTML 表格,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25243569/

相关文章:

javascript - 如果数组中的任何项 === x 则返回 false

javascript - 当我尝试为我的待办事项列表应用程序创建 LI 元素时,我的浏览器屏幕上没有显示任何内容

php - 评论专家意见的jquery动态分页

html - 在 div 中居中包含按钮的表单

html - 如何删除或更改 CSS 内联标题中图像之间的空格?

html - 我怎样才能隐藏除第一个以外的所有 <h2>?

javascript - 如何让div占据父div的全宽

javascript - react-redux 仅在数据到达时渲染

javascript - commitHandler 中未命中 Ajax 函数

javascript - jQuery 代码中的基本问题