Jump to content

AJAX refresh


blufish

Recommended Posts

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>

Link to comment
https://forums.phpfreaks.com/topic/108687-ajax-refresh/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.