Jquery 数据表:如何在数据表行中显示json数据?
我收到来自服务器的以下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,
{
"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"
} ]