How to get the data in different keys of an ajax response?

How to get the data in different keys of an ajax response?

wohcknahwohcknah Posts: 2Questions: 1Answers: 0

The structure of the ajax reponse is like below:

{
  "metadata": {
    "foo": "",
    "bar": "",
  },
  "maindata": [
    {...},
    {...},
    ...
  ]
}

I need to fill the data in "maindata" to the table body, and use the data in "metadata" for the table info. How to do it with one ajax request?

Answers

  • allanallan Posts: 63,494Questions: 1Answers: 10,470 Site admin

    the data in "maindata" to the table bod

    Use the ajax.dataSrc option.

    and use the data in "metadata" for the table info

    What table info?

    Allan

  • wohcknahwohcknah Posts: 2Questions: 1Answers: 0

    Hi allan,

    "table info" refers to the "Showing xx to xx of xx entries" on the left bottom of the table (not sure what's its official name).

  • allanallan Posts: 63,494Questions: 1Answers: 10,470 Site admin

    You can use info.callback to modify the default message if the language string options don't suit your needs.

    Allan

Sign In or Register to comment.