jQuery数据表未知参数

时间:2018-07-04 12:03:40

标签: datatables

我在jquery数据表中遇到问题,即“ DataTables警告:表id = paginatedTable-请求的未知参数'0'用于第0行第0列。有关此错误的更多信息,请参见http://datatables.net/tn/4“ < / p>

my.js

$(document).ready(function() {
    $('#paginatedTable').DataTable({
        "processing" : false,
        "serverSide" : true,
        "pageLength" : 1,
        ajax : {
            url : 'myurl',
             "contentType": "application/json; charset=utf-8",
             "dataType": "json", 
            dataFilter : function(data) {

                return data; 
            },
            "columns" : [ {
                "data" : "orderId",sDefaultContent: "n/a"
            }, {
                "data" : "customer",sDefaultContent: "n/a"
            }, {
                "data" : "amount" ,sDefaultContent: "n/a"
            }, {
                "data" : "date", sDefaultContent: "n/a"
            }, {
                "data" : "status",sDefaultContent: "n/a"
            }, {
                "data" : "paymentModule",sDefaultContent: "n/a"
            } ]
        }
    });
});

Data.json

{
    "draw": "1",
    "recordsFiltered": "2",
    "recordsTotal": "2",
    "data": [
        {
            "orderId": "2",
            "customer": "Rehan Afridi",
            "amount": "887",
            "date": "2018-06-22",
            "status": "DELIVERED",
            "paymentModule": "moneyorder"
        },
        {
            "orderId": "1",
            "customer": "aD SDAFASD",
            "amount": "887",
            "date": "2018-06-22",
            "status": "ORDERED",
            "paymentModule": "moneyorder"
        }
    ]
}

1 个答案:

答案 0 :(得分:0)

检查指向错误https://datatables.net/manual/tech-notes/4的链接。检查您的“ #paginatedTable”表结构。

阅读此错误文档,我认为您的错误可能有两个原因:

  

表的正文中有一个colspan或rowpan,而DataTables不支持。

  

使用column或columnDef,您指定的列比HTML中的列多。