I have a stat.dat file in which there is a number and it calls for include "stat.dat"; How to make this div block update every 10 seconds for example (there will be a lot of blocks)

1 answer 1

If you are using jQuery, then something like this:

$(document).ready(function () { var intervalID = window.setInterval(myCallback, 10000); function myCallback() { $.ajax({ url: "index.php", dataType: "json", type: 'POST', }).done(function (data) { $("#divId").text(data); }).fail(function (jqXHR, textStatus) { console.log(jqXHR); }); } } 

on server side:

  $filePath = "путь к файлу/stat.dat"; if (file_exists($filePath)) echo file_get_contents(); else echo 0;