JQuery Datatable Error“无法读取未定义的jquery.dataTables.min.js的属性长度:45

时间:2015-07-27 17:46:09

标签: javascript jquery ajax datatable

我正在进行AJAX调用以检索数据,并以JSON格式返回数据。但是我收到一个错误,没有任何东西返回到数据表。数据以这种格式返回:

[
{
    "part_number": "630000311",
    "qty": "1",
    "description": "PUMP, ACE PRODUCT 04 & OLDER",
    "point": "1",
    "cost": "535.23",
    "vendor_name": "Ace Pump Corporation",
    "total_sold": "5"
},
{
    "part_number": "400200179",
    "qty": "0",
    "description": "SEAL, DOOR CAB",
    "point": "2",
    "cost": "21.32",
    "vendor_name": "Angus-Palm Greeneville Inc",
    "total_sold": "44"
}
]

这是我的Jquery:

             $('#partTable').DataTable({
            "processing": true,
            "searching": false,
            "responsive": true,
            "ajax": { "async": "false", "url": "/vvvv/vvvWS.php", "type": "GET", "data": function (c) { c.locations = locations; c.percentages = percentages; } },
            "columns": [{"data": "part_number", "data": "qty", "data": "description", "data": "point", "data": "cost", "data": "vendor_name", "data": "total_sold"}]
        });

1 个答案:

答案 0 :(得分:0)

如果有人偶然发现这个,我用JSON数据的格式解决了这个问题,这是新的格式:

{
"data":
[
{
"part_number": "630000311",
"qty": "1",
"description": "PUMP, ACE PRODUCT 04 & OLDER",
"point": "1",
"cost": "535.23",
"vendor_name": "Ace Pump Corporation",
"total_sold": "5"
},
{
"part_number": "400200179",
"qty": "0",
"description": "SEAL, DOOR CAB",
"point": "2",
"cost": "21.32",
"vendor_name": "Angus-Palm Greeneville Inc",
"total_sold": "44"
}
]
}