I am creating inbox mail at automatically refresh after 2 minutes, that displays new mail display in the datatable. How can refresh my datatable?
So you are using serverside processing. sth like this:
$(document).ready(function () {
var table = $('#TableID').DataTable({
"processing": true,
"serverSide": true,
//any other configuration options
"ajax": "path/to/processor"
});
you can force it auto refresh making table's ajax param to reload every 120 second:
setInterval(function () {
table.ajax.reload();
}, 120000);
Considering you're using server-side processing for the Ajax-sourced datatable, all you need to do is redraw the table after every 2 minutes.
You can use Javascript's setInterval() function
var oTable = $("#mytable").DataTable({
'serverSide': 'true'
});
After initialisation, use setInterval() to redraw the table with your desired time.
setInterval(function(){
oTable.draw();
}, 120000);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With