I want to reload a datatable after n amount of seconds.
$(document).ready(function() {
var table = $('#table_id').DataTable( {
"ajax": "http://192.168.1.134:8000/api/",
"columns": [
{ "data": "id" },
{ "data": "name" },
{ "data": "city" },
],
}
);
} );
setInterval(function(){
table.ajax.reload(null, false);
},5000);
But the total row in the table keeps being the same.
I find the answer in the Documenation
var table = $('#table_id').DataTable( {
"ajax": "http://192.168.1.134:8000/api/",
"columns": [
{ "data": "id" },
{ "data": "name" },
{ "data": "city" },
],
}
);
setInterval( function () {
table.ajax.reload(); // user paging is not reset on reload
}, 30000 );