Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/79.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 数据表:如何在数据表行中显示json数据?_Jquery_Datatables - Fatal编程技术网

Jquery 数据表:如何在数据表行中显示json数据?

Jquery 数据表:如何在数据表行中显示json数据?,jquery,datatables,Jquery,Datatables,我收到来自服务器的以下json响应: { "rData": { "total": 17, "per_page": 3, "current_page": 1, "last_page": 6, "next_page_url": "http://localhost:9901/securityquestionlist/?page=2", "prev_page_url": null,

我收到来自服务器的以下json响应:

    {
    "rData": {
        "total": 17,
        "per_page": 3,
        "current_page": 1,
        "last_page": 6,
        "next_page_url": "http://localhost:9901/securityquestionlist/?page=2",
        "prev_page_url": null,
        "from": 1,
        "to": 3,
        "data": [
            {
                "question": "Accessor: 15th question",
                "full_name": "Dave Alex"
            },
            {
                "question": "Accessor: 14th question",
                "full_name": "Dave Alex"
            },
            {
                "question": "Accessor: 13th question",
                "full_name": "Dave Alex"
            }
        ]
    }
 }
我有以下HTML代码:

 <table id="IdSQLTable" class="table table-striped table-bordered table-hover">
     <thead>
         <tr><th>Question</th></tr>
     </thead>
     <tbody></tbody>
 </table>
我无法在表中打印“问题”。有人能告诉我怎么做吗

将ajax.dataSrc设置为目标rData.data:

并相应更改列定义:

"columnDefs": [ {
    "targets": [ 0 ],
    "data": 'question',
    "defaultContent": "Click to edit"
} ] 
然后它工作->

ajax : {
  url: 'http://localhost:9901/securityquestionlist',
  dataSrc : function(json) {
     return json.rData.data;
  } 
  ...
}
"columnDefs": [ {
    "targets": [ 0 ],
    "data": 'question',
    "defaultContent": "Click to edit"
} ]