Jquery data table not updating real-time data

I have a data table and using ajax to retrieve the data and display the html DOM on my page. But the problem is that after implementing server processing for the data table, I finally have records in my html table via ajax, but when I make changes to my database, this change is not reflected in my data table until I update page. Then, what effect of using ajax in the data table do you still need to update to see the changes.

My ajax code to select data

$(document).ready(function() {
$('#example').DataTable( {
    "processing": true,
    "serverSide": true,
    "ajax": "rendringMain.php"
} );

My rendringMain.php looks just like this link https://datatables.net/examples/server_side/simple.html , but a few changes

+4
source share
1 answer

You can use the following solution to update your data type every 5 seconds:

window.setInterval( 
$("table[id='example']").DataTable().ajax.reload();
, 5000);
+4
source

Source: https://habr.com/ru/post/1695639/


All Articles