Hi ,
How to refresh particular DIV every few second....
| SitePoint Sponsor |
Hi ,
How to refresh particular DIV every few second....


Programming Group Advisor
Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
Car is to Carpet as Java is to JavaScript
Hi Paul,
Digging for an answer to a similar problem I have now, I found your answer.
Can you please give an example on how to do what you mentioned(iframe)?
Thanks in advance.


Programming Group Advisor
Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
Car is to Carpet as Java is to JavaScript
Thanks Paul,
Can I put a php instead of html?
How do you make it refresh at a give time interval?


You would put a meta-tag in the page that the iframe is loading, to perform the refresh. See http://reference.sitepoint.com/html/meta
Programming Group Advisor
Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
Car is to Carpet as Java is to JavaScript
Thank you Paul, I will do just that.
@Paul: do we really advise people to use iframes? (I'm personally not fond of iframes at all...)


iframes are not the only answer - it's preferable now to use setInterval to trigger an ajax request, and update the div in that manner.
If using jQuery it would be something like:
Code javascript:$('#target').data('timedupdate', window.setInterval(function () { $('#target').load('http://aaa.bbb.com/pagetoupdatefrom.html'); }, 5000));
The data part gives you the ability to use clearInterval on that timedupdate at some later stage, should you decide you want to do so.
Programming Group Advisor
Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
Car is to Carpet as Java is to JavaScript
Bookmarks