I have a page that loads with $ .ajax () from JQuery, ajax pulls a page in php with a database that is updated constantly and I need to keep the page up to date, how would it be the best way?
I've read about using asetTimeOut( '', 2000 );
but I thought it would weigh so much that it would be impractical, and I also read about a timeout in jquery's own ajax but it did not work, I updated the database and the page remained the same, I used this example in the script :
$(document).ready(function(){
site();
});
function site() {
$.ajax({
url: "site.php",
method: 'POST',
dataType: 'json',
success: function (data) {
console.log(data);
},
error: function (data) {
console.log(data);
},
timeout: 3000
});
}
I added timeout this way and nothing has changed!