ajax refresh of tbody in table retains old values
ajax refresh of tbody in table retains old values

The below when run initial causes search to properly work,
When the ajax runs again to refresh table data, the search caches the original table data and does
not recognize the new data.
How to fix?
ajax here
then...
$("div.mytable").find("table tbody").html(ajaxreturn)
$("div.mytable").find("table".)DataTable()
I tried .clear() but then search does not return anything
This discussion has been closed.
Answers
Using
html(ajaxreturn)
updates the table in the DOM but Datatables knows nothing about the change. You can either usesclear()
followed byrows.add()
to update the Datatable. Or you can continue to use$("div.mytable").find("table tbody").html(ajaxreturn)
followed byrows().invalidate()
to have Datatabiels updates its data cache with the refreshed data.Kevin
See code below. The same result is occurring.
Am I properly applying the recommended .row().invalidate() functions?
First population:
$.ajax({data:{"reqtyp":"EPARRetrieveResearch",uid:uid,dayshist:dayshist},url: "server/file.asp",cache:false}).done(function(runner)
{
//WATCH 11132019
Second population:
Without having a test case to experiment with I'm not sure the best approach. You could try
rows().invalidate()
with thedom
parameter, for example:dtbl.rows().invalidate('dom')
. Or you could trydestroy()
then reinitialize Datatables, for example:Kevin
Thank you for the help. This below worked with your suggestion of using .destroy()