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

Popular posts from this blog

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

html - How to style widget with post count different than without post count -

url rewriting - How to redirect a http POST with urlrewritefilter -