How to load data in datatables from ajax?
Load data in Datatables from Ajax
I was working on a project in which I had to show results in datatables with search and load data in datatable in real-time like whenever record inserted, it will show in datatables right away without refreshing page. This can be done via ajax. I achieved this requirement by following code. I am skipping table html.
var recordsTable; recordsTable = $('#datatable-fixed-header').DataTable({ ajax: { "url":"liveRecs.php", "dataSrc": "" } }); setInterval( function () { recordsTable.ajax.reload( null, true ); }, 10000 );
That’s it. Hope this will help.