Forum Moderators: open
I've just got a plain page, index.php:
<P>Blah blah blah.<DIV ID="mydiv"><?php include('otherpage.php');?></DIV>
<P>Blah blah blah blah blah.
All I want is for that DIV to refresh every 30 seconds or so, without refreshing the rest of the page and without using an IFRAME. The "otherpage.php" contains information pulled from a MySQL database, so it'll update periodically and I'd like it to appear "semi-live" inside that DIV on index.php.
One of the only things I've found here on this site is this older thread [webmasterworld.com], but it didn't provide any examples, and I may require a little more handholding. Any takers? I would be very grateful.
1. in the initial page setup, keep the contents of the containing DIV empty.
2. change the contents of the PHP page to ONLY include the content you would like viewable in the containing DIV. Meaning make sure it is not sending any DOCTYPE, html, body, or header tags.
3. on page load call a function that creates an XMLHttpRequest object and sends it to the PHP page you just created. The return function should then first check to make sure the innerHTML of the containing DIV is empty, and if not, clear it. At that point, jsut set the innerHTML = XMLHttpRequest.responseText.
4. recursively call the function every 30 seconds.
Hope that helps!