根据此处的文档,我已经实现了服务器端代码。
JS代码
$('#datatable_paging').dataTable({
"bProcessing": true,
"bServerSide": true,
"sAjaxSource": "#### my php file path ####",
});
我将 JSON 数据作为
{
"sEcho": 0,
"iTotalRecords": 19,
"iTotalDisplayRecords": "19",
"aaData": [
["1", "peter", "peter@gmail.com"],
["2", "john", "john@yahoo.com"],
["3", "raj", "raj@in.com"],
["4", "selvin", "selvin@gmail.com"],
["5", "ismail", "ismail@gmail.com"],
["6", "muadth", "muad@hotmail.com"],
["7", "ahmed", "ahmed@gmail.com"],
.....
]
}
现在我需要使用 Datatable 分页在下表中显示这个 JSON 结果
HTML 代码
<table id="datatable_paging">
<thead>
<tr>
<th>Id </th>
<th>Name</th>
<th>E-mail</th>
</tr>
</thead>
</table>