Refresh datatable without using ajax
Refresh datatable without using ajax
Hi all
I'm trying without great success to refresh the content of a datatable without using ajax - using a button.
Data itself is being presented from an SQL query directly on the page.
When the pages opens, data appears as expected.
But when I change the data within the db, then click the reload button, the onClick event (below) does fire, and the table is cleared successfully, but then the table isn't refreshed/reloaded/redrawn at all - remains empty/cleared.
$('#btn-reload').on('click', function(){
table
.clear()
.draw()
});
Any ideas would be massively appreciated. Many thanks in advance.
Answers
The problem is Datatalbes is not configured to retrieve the data. You will probably need to reload the data using your direct SQL injection. Maybe this order will work:
destroy()
to destroy the DatatableThis might need adjusting depending on exactly what you are doing.
Kevin