blufish Posted June 4, 2008 Share Posted June 4, 2008 Okay, so I made/got/edited this code, it should refresh the content within a div every 5 seconds, all it does is load it the first time. Any ideas on how to fix this? thanks. <script type="text/javascript"> window.onload="loadurl(dest)"; { // http://aleembawany.com/2005/09/01/ajax-instant-tutorial/ function loadurl(dest) { var dummy = "yay!"; try { xmlhttp = window.XMLHttpRequest?new XMLHttpRequest(): new ActiveXObject("Microsoft.XMLHTTP"); } catch (e) { } xmlhttp.onreadystatechange = triggered; xmlhttp.open("GET", dest); xmlhttp.send(null); } function triggered() { if ((xmlhttp.readyState == 4) && (xmlhttp.status == 200)) { document.getElementById("output").innerHTML = xmlhttp.responseText; } setTimeout ( "loadurl('reader.php')" , 5000); } } </script> Quote Link to comment Share on other sites More sharing options...
blufish Posted June 6, 2008 Author Share Posted June 6, 2008 Nobody knows why this isn't working? Quote Link to comment Share on other sites More sharing options...
haku Posted June 6, 2008 Share Posted June 6, 2008 You have to set 'dest' before you call it in the window.onload function. Right now it is passing an empty variable, which means that it doesn't know the URL to access. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.