簡體   English   中英

未使用jQuery的Datatables插件從Ajax調用中填充表

[英]Table not being filled from Ajax Call using Datatables plug-in for jQuery

ajax請求返回以下數據

    [{"ID":40,"Date":"\/Date(1407999600000)\/"},{"ID":39,"Date":"\/Date(1409036400000)\/"}

HTML是:

<table id="bookings-table" class="display">
<thead>
    <tr>
        <th>ID</th>
        <th>Date</th>
    </tr>
</thead>
<tfoot>
    <tr>
        <th>ID</th>
        <th>Date</th>
    </tr>
</tfoot>
</table>

而JavaScript是

$(document).ready(function () {
    $('#bookings-table').dataTable({
        "ajaxSource": "/manager/Booking/GetBookings",
        "columns": [
        { "data": "ID" },
        { "data": "Date" }
        ]
    });
});

不知道為什么表格沒有被填充

只看他們的文檔 ,我相信您的json必須被格式化。

{
    "data": [
        {
            "ID": 40,
            "Date": "\/Date(1407999600000)\/"
        },
        {
            "ID": 39,
            "Date": "\/Date(1409036400000)\/"
        }
    ]
}

JavaScript錯誤

    $('#bookings-table').dataTable({
        "ajax": {
            "url": "/manager/Booking/GetBookings",
            "dataSrc": ""
        },

排序后,所有列現在綁定

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM