【发布时间】:2017-09-20 06:20:57
【问题描述】:
我正在尝试使用具有服务器端功能的数据表。但是当它试图获取给我这个错误的数据时;关闭它后,正确地重新加载数据。
DataTables warning: table id=clientTable -
如您所见;没有对警告的解释。我也没有任何控制台警告。这是我的代码:
表格 HTML
<table class="table table-striped table-hover table-bordered" id="clientTable">
<thead>
<tr>
<th>ID</th>
<th>Name</th>
<th>Phone</th>
<th>Mail</th>
<th>Date</th>
<th>Auto</th>
</tr>
</thead>
</table>
数据表初始化
$('#clientTable').dataTable({
"iDisplayLength": 20,
"processing": true,
"serverSide": true,
"ajax": clientApiConstant,
"columns":
[
{ "data": "id",},
{ "data": "name" },
{ "data": "phone" },
{ "data": "mail" },
{ "data": "date" },
{ "data": "auto" }
]
});
客户端 API 响应
{
"data": [
{
"id": 2,
"name": "John Doe",
"date": "2017-04-04T00:00:00+0000",
"mail": "arda@asd.com",
"phone": "123123123",
"auto": true
},
{
"id": 3,
"name": "Doe John",
"date": "2017-04-22T00:00:00+0000",
"mail": "nihatcan@asd.com",
"phone": "234234234",
"auto": false
}
],
"recordsTotal": 2,
"recordsFiltered": 2,
"error": []
}
回应 Dipak 的回答;这是我的 datatables.js 失败的地方:
function K(a, b, c, d) {
c = "DataTables warning: " + (a ? "table id=" + a.sTableId +
" - " : "") + c;
d && (c += ". For more information about this error, please see http://datatables.net/tn/" + d);
if (b)
E.console && console.log && console.log(c);
else if (b = m.ext, b = b.sErrMode || b.errMode, a && s(a, null, "error", [a, d, c]), "alert" == b)
alert(c);
else {
if ("throw" == b)
throw Error(c);
"function" == typeof b && b(a, d, c)
}
}
at "function" == typeof b && b(a, d, c) 行;第 1763 行 @ 版本 1.10.15
【问题讨论】:
标签: jquery ajax datatable server-side