数据表 1.10 - 不显示结果

Ker*_*nes 1 html jquery datatables jquery-datatables datatables-1.10

这是我的设置。

Javascript/jQuery:

$('#list').dataTable({
    paging: false,
    serverSide: true,
    ajax: {
        url: "/search/",
        data: function (d) {
            return $.extend({}, d, {
                lid: Label.selectedId
            });
        }
    }
});
Run Code Online (Sandbox Code Playgroud)

HTML

<table id="list" class="table table-striped" width="100%">
    <thead>
    <tr>
        <th>Title</th>
        <th>First Name</th>
        <th>Last Name</th>
        <th>URL</th>
    </tr>
    </thead>
    <tbody>

    </tbody>
</table>
Run Code Online (Sandbox Code Playgroud)

JSON 响应

{"data": [["Test", "", "", ""]], "recordsTotal": 1, "draw": 1, "recordsFiltered": 1}
Run Code Online (Sandbox Code Playgroud)

通过这样做手动调用它:

$('#list').DataTable().ajax.reload();
Run Code Online (Sandbox Code Playgroud)

但表不会改变。我已经用 DataTables 1.9 做了很多次了,没有任何问题——有什么想法吗?


更新

我发现如果我关掉serverSide它,它会起作用。

Ker*_*nes 5

我发现了问题。它与drawJSON 响应中的 。一直是1。

如果使用serverSide: true,则意味着它将draw作为变量发送,并且必须返回。

更多信息在这里:http : //datatables.net/manual/server-side