anyone know how to make a page (txt page) reload every so many seconds without refreshing the page.. mentor made one awhile ago but it doesn't work.
anyone know how to make a page (txt page) reload every so many seconds without refreshing the page.. mentor made one awhile ago but it doesn't work.
.:.:#14:.:. .:.: Impossible Is Nothing :.:. .:.: 845 Rep:.:.
.:.: Stand up for what is right, even if you stand alone:.:.
try using script.aculo.us
Im pretty sure the script did work by the end of it? although i finalized outside forums. Its pretty simple to do without even changing the function anyway:
Heres a quick usage of my ajax page loading script to acheave the desired effect
Only change from orignal is use of interval function to call it every so often.Code:// sets time between reloads in miliseconds setInterval(LoadPage("INFOFILE.php","DIVNAME"), 30000); function LoadPage(page,usediv) { // Set up request varible try {xmlhttp = window.XMLHttpRequest?new XMLHttpRequest(): new ActiveXObject("Microsoft.XMLHTTP");} catch (e) { alert("Error: Could not load page.");} //send data xmlhttp.onreadystatechange = function(){ //Check page is completed and there were no problems. if ((xmlhttp.readyState == 4) && (xmlhttp.status == 200)) { //Write data returned to page document.getElementById(usediv).innerHTML = xmlhttp.responseText; } } xmlhttp.open("GET", page); xmlhttp.send(null); }
Just chnage INFOFILE.php to the file name of the page you want to load from, and DIVNAME to the ID of the div you want to place the content returned in.
*other none essental changes made.
Removed, return false as served no purpous. Scroll to top, becuse it would be annoying, and page loading message since it would be in the way alot
Easy as pie![]()
Last edited by Mentor; 02-06-2007 at 10:54 PM.
thanx mentor. still isn't working for me?
Last edited by Colin-Roberts; 02-06-2007 at 11:35 PM.
.:.:#14:.:. .:.: Impossible Is Nothing :.:. .:.: 845 Rep:.:.
.:.: Stand up for what is right, even if you stand alone:.:.
it isnt erroring out anything it just leaves my div blank and loads nothing
.:.:#14:.:. .:.: Impossible Is Nothing :.:. .:.: 845 Rep:.:.
.:.: Stand up for what is right, even if you stand alone:.:.
Want to hide these adverts? Register an account for free!