Updating html code with javascript when php return changed -
i want continuously update html document using return of php file. therefore need use jquery function:
$.get('returnfunction.php', function(data) { test=data; document.getelementbyid('t1').innerhtml=test; }); how can call function continuously in javascript? setinterval seems not proper asynchronous function.
thanks
the problem calling asynchronous function using setinterval unanswered requests might accumulate if server or network slow.
here's how might :
(function doone(){ $.get('returnfunction.php', function(data) { test=data; document.getelementbyid('t1').innerhtml=test; settimeout(doone, 1000); }); })(); this way next call $.get occurs 1 second after server has answered last call.
you might want act on failures, not on success, depending on exact requirements.
Comments
Post a Comment