单击服务器端分页时,无法在Jquery数据表中显示JSON响应

时间:2017-06-23 07:26:18

标签: jquery datatable jquery-pagination server-side-scripting

我是jquery datatable的新手,所以我需要帮助解决这个问题:

每当点击'Next'页面时,api就会被调用,响应json也会显示在datatable中。 现在,单击“上一页”页面按钮,api即被调用,并且能够从后端获得响应,但数据表未使用新的JSON数据重置。

请指导我解决此问题。

以下是我的代码:

使用Javascript:

$(document).ready(function() { 
var empColumns = [];
empColumns.push({
    "sTitle" : "Emp.Id",
    "sClass" : "left",
    "sWidth" : "10%"
}, {
    "sTitle" : "Name",
    "sClass" : "left",
    "sWidth" : "10%"
}, {
    "sTitle" : "Designation",
    "sClass" : "left",
    "sWidth" : "10%"
});


$("#example").dataTable( {
    "bProcessing": false,
    "bServerSide": true,
    "sort": "position",
    "bStateSave": false,
    "iDisplayLength": 10,
    "iDisplayStart": 0,        
    "sAjaxSource": "api/getEmpDetails",      
    "aoColumns": empColumns
});
});

JSON数据:

{
  "draw": 1,
  "recordsTotal": 57,
  "recordsFiltered": 57,
  "data": [
   [
  "1",
  "Marshall",
  "Regional Director"
],
[
  "2",
  "Hurst",
  "Javascript Developer"
],
[
  "3",
  "Rios",
  "Personnel Lead"
],
[
  "4",
  "Snider",
  "Customer Support"
],
[
  "5",
  "Wilder",
  "Sales Assistant"
],
[
  "6",
  "Camacho",
  "Support Engineer"
],
[
  "7",
  "Green",
  "Chief Operating Officer (COO)"
],
[
  "8",
  "Winters",
  "Accountant"
],
[
  "9",
  "Joyce",
  "Developer"
],
[
  "10",
  "Cortez",
  "Team Leader"
]
]
}

提前致谢....

0 个答案:

没有答案