首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >REST API -使用JQUERY将JSON数据转换为HTML表

REST API -使用JQUERY将JSON数据转换为HTML表
EN

Stack Overflow用户
提问于 2018-11-29 08:51:28
回答 1查看 793关注 0票数 1

我想通过Jquery将API中的数据显示到HTML表中,但它没有将数据显示到表中。

代码语言:javascript
复制
        <thead>
            <tr>
                <th>A</th>
                <th>B</th>
                <th>C</th>
            </tr>
        </thead>
        <tbody id="mydata">
            <tr>
                <td>[[E]]</td>
                <td>[[F]]</td>
                <td>[[G]]</td>
            </tr>           
        </tbody>
    </table>
    </div>

    <script>
        function UserAction() {
    var xhttp = new XMLHttpRequest();
    xhttp.onreadystatechange = function() {
         if (this.readyState == 4 && this.status == 200) {
             alert(this.responseText);
         }
    };
    xhttp.open("GET", "https:xxxxxxx", true);
    xhttp.setRequestHeader("Content-type", "application/json");
    xhttp.setRequestHeader("Authorization", "Bearer eyJhbGciOiJIUzI1Nixxxxxxx");
}
    $("#mydata").mirandajs(xhhtp);
    </script>

关于JSON响应,我想获取播放器、时间戳和原因,并将数据呈现到表中(在示例E,F,G中)这里是API响应

代码语言:javascript
复制
{
    "meta": {
        "active": 2,
        "expired": 275,
        "total": 277
    },
    "links": {
        "next": "https://api.xxxxxxx"
    },
    "data": [
        {
            "type": "xxx",
            "id": "xxxx",
            "meta": {
                "player": "Serbo"
            },
            "attributes": {
                "id": "xxxx",
                "uid": "xxxx",
                "timestamp": "2018-07-11T13:02:14.663Z",
                "reason": "xxxxxxx",
                "note": null,
                "identifiers": [
                    {
                        "id": xxxxxxx,
                        "type": "xxxxxxx",
                        "identifier": "xxxxxxx",
                        "private": true,
                        "lastSeen": "2018-08-17T16:23:24.865+00:00"
                    }
                ]

请注意,我需要来自json对象内部的数据,然后是属性对象内部的数据。

EN

回答 1

Stack Overflow用户

发布于 2018-11-29 12:34:29

解决了它,这是关于我调用API的方式

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/53530286

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档