Unable to update table with new SQL query and JSON response
Unable to update table with new SQL query and JSON response
I have a datatable that I initialize on load of the web page. It does AJAX POST and the table is filled using a SQL query. I have a menu (external to datatables) that when clicked should update the table using AJAX using a modified SQL query based upon the menu item selected. I can see the JSON response but can't seem to figure out how to update the table. I'm using datatables 1.10.16. Any ideas on what I'm missing in my menu item's click event (PHP) that should update the table with the new JSON response? Thanks in advance!
ajax.reload() doesn't work.
Answers
Is your ajax part of your datatables? I suspsect not so reload does not work. If your data is fetched external to DataTables, you are going to have to use the clear out the existing and add new. Reload is intended for when ajax is part of your Datatable initialization
rows.add()
is how to add new rows. As bindrid mentioned you may want to useclear()
to clear the table first, depending on your requirements.Kevin