0

I am new to jquery datatables. I have a json format returning from the server in the below format:

{
  "links": [
    {
      "rel": "self",
      "href": "http://hostname:port/state/city/1"
    }
  ],
  "name1": "value1",
  "name2": "value2",
  "name3": "value3",
  "name4": "value4"

}

In the javascript I am using the below code to display in the table:

<script>
  $(function  ()  {
    $('#dataTable').dataTable( {
      "bJQueryUI": true,
      "sPaginationType": "full_numbers",
      "sAjaxSource": "partials/records.txt",
      "aoColumns": [
        { "mData": "name1" },
        { "mData": "name2" },
        { "mData": "name3" },
        { "mData": "name4" },
      ]
    });
  });
</script>

I am getting error and the data is not getting displayed in the table. How to display the above json format in the datatable? To my limited knowledge, I see that I do not have "sAjaxDataProp": "list", in the script? Is the error because of the sAjaxDataProp property?

Please let me know where I am going wrong.

1 Answer 1

0

I found the solution for my query. The format of the json should is not correct. The json should contain sAjaxDataProp value. The json should be formatted before it is consumed by the datatable. Details can be found in the below link: Using ajax to load a jQuery DataTable

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.