Initializing a datatable with Ajax object as data source

Initializing a datatable with Ajax object as data source

yajmendezyajmendez Posts: 3Questions: 1Answers: 0
edited March 2018 in Free community support

So i don't know if the format of my object is the problem or the data type, but i believe it is quite correct.

MY CODE

i'm quite unsure on what to put on the "ajax" : " "

so i just inserted the return value there.

additional screenshots of the return value

the record name, is the route of the page.

This question has an accepted answers - jump to answer

Answers

  • bindridbindrid Posts: 730Questions: 0Answers: 119

    change ajax:data to data:data. You don't need ajax in your table because your table is part of ajax. (just make sure it is desterilized.)

  • yajmendezyajmendez Posts: 3Questions: 1Answers: 0

    Hello, i tried your suggestion but it seems not to work still.

    Here is the process, and as we can see, the data is right there, and it is not just calling it right.

    The code:

    The JSON Lint of the return data:

    What do you mean by destrerilized, i'm sorry, i'm quite new to Javascript.

  • kthorngrenkthorngren Posts: 21,301Questions: 26Answers: 4,946
    Answer ✓

    What do you mean by destrerilized

    This means to convert from JSON to a Javascript object. Above your console.log place this command:
    data = JSON.parse(data);

    This will do the conversion.

    Since your data is in the data object you will probably need to use "data": data.data, instead of "data": data,.

    Kevin

  • yajmendezyajmendez Posts: 3Questions: 1Answers: 0

    Thank you so much!

This discussion has been closed.