Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/89.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Jquery 表中没有响应成功的可用数据_Jquery_Html_Json_Datatable_Datatables - Fatal编程技术网

Jquery 表中没有响应成功的可用数据

Jquery 表中没有响应成功的可用数据,jquery,html,json,datatable,datatables,Jquery,Html,Json,Datatable,Datatables,我在Firefox中检查了网络监视器,它说我成功地获取了Json数据。从弹簧导轨上看,它应该是: { "id": 37658, "content": "Hello, World!" } 但我的数据表中没有可用的数据。我错过什么了吗 完整代码在 表: <table id="example" class="display" style="width: 100%"> <thead> <tr>

我在Firefox中检查了网络监视器,它说我成功地获取了Json数据。从弹簧导轨上看,它应该是:

{
  "id": 37658,
  "content": "Hello, World!"
}
但我的数据表中没有可用的数据。我错过什么了吗

完整代码在

表:

    <table id="example" class="display" style="width: 100%">
        <thead>
            <tr>
            </tr>
        </thead>
    </table>

脚本:

<script>

$(document).ready(function() {
    $('#example').DataTable({
        "ajax" : {
            "dataType" : 'json',
            "contentType" : "application/json; charset=utf-8",
            "url" : "http://rest-service.guides.spring.io/greeting",
            "dataSrc" : "",
        },
        columns: [{
            data: "id",
            name: "id",
            title: "Id"
            }, 
         {
            data: "content",
            name: "content",
            title: "content"
        }]
    });         
});

</script>

$(文档).ready(函数(){
$('#示例')。数据表({
“ajax”:{
“数据类型”:“json”,
“contentType”:“application/json;charset=utf-8”,
“url”:”http://rest-service.guides.spring.io/greeting",
“dataSrc”:“,
},
栏目:[{
数据:“id”,
姓名:“id”,
标题:“Id”
}, 
{
数据:“内容”,
名称:“内容”,
标题:“内容”
}]
});         
});

我的列语法不正确。其固定值如下,并添加了一些参数:

<script>
$(document).ready(function() {
        $('#example').DataTable({
            "ajax" : {
                "dataType" : 'json',
                "contentType" : "application/json; charset=utf-8",
                "url" : "http://rest-service.guides.spring.io/greeting",
                "dataSrc" : "",
            },
        "columns": [
            { "data": "id"},
            { "data": "content"}
        ]
        });         
    }); 
</script>

$(文档).ready(函数(){
$('#示例')。数据表({
“ajax”:{
“数据类型”:“json”,
“contentType”:“application/json;charset=utf-8”,
“url”:”http://rest-service.guides.spring.io/greeting",
“dataSrc”:“,
},
“栏目”:[
{“数据”:“id”},
{“数据”:“内容”}
]
});         
}); 

返回的JSON应该是一个对象数组,您只返回一个对象。谢谢。我使用了一个带有对象数组的api,现在出现了以下错误:“DataTables警告:table id=example-为第0行第0列请求了未知参数“0”。“请参阅此处:请尽最小努力阅读文档->您需要声明列;DT应该如何知道将接收到的JSON内容放在哪里?用叉子叉起你的叉子来演示->