jQuery DataTables - 没有XHR请求

时间:2014-08-03 14:36:54

标签: javascript jquery ajax json datatables

我有一个带有以下初始化选项的简单数据表:

$('#inventory').dataTable({
    "sPaginationType": "full_numbers",
    "ajax": '/api/inventory/',
    "columns": [
        { "data": "id" },
        { "data": "description" },
        { "data": "cost_price" },
        { "data": "sale_price" },
        { "data": "on_hand" }
    ]
});

HTML:

<table id="inventory">
    <thead>
        <tr>
            <th tabindex="0" rowspan="1" colspan="1">ID</th>
            <th tabindex="0" rowspan="1" colspan="1">Description</th>
            <th tabindex="0" rowspan="1" colspan="1">Cost Price</th>
            <th tabindex="0" rowspan="1" colspan="1">Sale Price</th>
            <th tabindex="0" rowspan="1" colspan="1">On Hand</th>
        </tr>
    </thead>

    <tfoot>
        <tr>
            <th rowspan="1" colspan="1">ID</th>
            <th rowspan="1" colspan="1">Description</th>
            <th rowspan="1" colspan="1">Cost Price</th>
            <th rowspan="1" colspan="1">Sale Price</th>
            <th rowspan="1" colspan="1">Stock</th>
        </tr>
    </tfoot>
    <tbody>
    </tbody>
</table>

这是我的debug bookmarklet。我注意到在服务器交互下它显示Last JSON from server: No XHR request made。在前端,我看到No data available in table我的数据应该在哪里。 Chrome控制台中没有错误,如果我使用浏览器点击该网址,则返回JSON罚款。什么可能导致DataTables不发出XHR请求?

0 个答案:

没有答案