我在DataTable无法正常工作时遇到问题(ajax没有关闭)

时间:2017-08-09 13:38:58

标签: asp.net-mvc datatables

我正在学习本教程:

https://gist.github.com/ChinhP/9b4dc1df1b12637b99a420aa268ae32b

我有一个问题,即ajax不会触发。有什么建议?

我正在尝试使用上一个,下一个,第一个和最后一个按钮来获取表格。

var data = { "number": 0, "currentPosition": 1 };
console.log(JSON.stringify(data));

//var output = "";

/*$.ajax('/Companies/GetData', {
datatype: 'json',
contentType: 'application/json',
type: 'post',
data: JSON.stringify({ dataTableParameters: data }),
success: function (response) {
    output = response;
}
});*/

$(document).ready(function () {
$('#CompanyTable').dataTable(
    {
        "sPaginationType": "full",
        processing: true,
        bserverSide: true,
        ajax: {
            "url": "../Companies/GetData",
            "type": "POST",
            "contentType": "application/json",
            data: function (d) {
                console.log('enter');
                // note: d is created by datatable, the structure of d is 
the same with DataTableParameters model above
                console.log(JSON.stringify(d));
                return JSON.stringify(d);
            },
            success: function (response)
            {
                console.log(response)
            }
        }

    });
 });

0 个答案:

没有答案