DataTables loading wrong results on ajax call
DataTables loading wrong results on ajax call
tangaye
Posts: 1Questions: 1Answers: 0
Can some please help me with this thread I have posted on stack overflow. I'm having problems getting the desire dataTables result on my ajax call. Here is my thread on stackoverlow: http://stackoverflow.com/questions/43209074/datatables-loading-wrong-results-on-ajax-call/
This discussion has been closed.
Answers
Datatables is flexible in how the data is sourced but you aren't is it in a method that will work. First I would recommend you read the page that discusses the types and sources of data supported:
https://datatables.net/manual/data/
Then take a look at the data sources examples:
https://datatables.net/examples/data_sources/index.html
If you want to change the data in the table then you will need to use Datatables API's to do so. Here are a few options depending on what your goal is:
https://datatables.net/reference/api/clear()
https://datatables.net/reference/api/destroy()
If you are going to use new ajax data each time the user clicks a button then you might want to place the json in a variable then use either of the following to add the data after clearing it using one of the above:
https://datatables.net/reference/api/row.add()
https://datatables.net/reference/api/rows.add()
This should get you started. Please post any questions.
Kevin