Unable to update table with new SQL query and JSON response

Unable to update table with new SQL query and JSON response

smackdatsmackdat Posts: 1Questions: 1Answers: 0
edited September 2017 in Free community support

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

  • bindridbindrid Posts: 730Questions: 0Answers: 119

    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

  • kthorngrenkthorngren Posts: 21,304Questions: 26Answers: 4,947

    rows.add() is how to add new rows. As bindrid mentioned you may want to use clear() to clear the table first, depending on your requirements.

    Kevin

This discussion has been closed.