Show JSON Data in Jquery Datatables

后端 未结 1 633
囚心锁ツ
囚心锁ツ 2021-01-17 02:58

I\'ve been trying to get my JSON data in jQuery DataTables component.

First I wrote the JavaScript code as well as a view as shown in the code below:



        
相关标签:
1条回答
  • 2021-01-17 03:09

    When using server-side processing with AJAX requests, it expects JSON data to be returned in the special format required by DataTables. The following fields of JSON response object are required: draw, data, recordsTotal and recordsFiltered. You need to bring your server response into accordance with expected format.
    For example, your first response should be as following:

    {
      "draw": 1,
      "recordsTotal": 4,
      "recordsFiltered": 4,
      "data": [
        {
          "numbers": "38",
          "name": "Bllaca"
        }, {
          "numbers": "28",
          "name": "Kaess"
        }, {
          "numbers": "27",
          "name": "droessmer"
        }, {
          "numbers": "24",
          "name": "friedricha"
        }
      ]
    }
    
    0 讨论(0)
提交回复
热议问题