Below is the code that I am having trouble with -
<script type="text/javascript" language="javascript">
function loadXMLDoc()
{
var xmlhttp;
if (window.XMLHttpRequest)
{// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
}
else
{// code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange=function()
{
if (xmlhttp.readyState==4 && xmlhttp.status==200)
{
document.getElementById("myDiv").innerHTML=xmlhttp.responseText;
}
}
xmlhttp.open("GET","<%=StatsURL%>",true);
xmlhttp.send();
}
function timedRefresh(timeoutPeriod) {
setTimeout(function(){loadXMLDoc(); autoRefresh();},timeoutPeriod);
}
</script>
And this is called in -
<body onload="JavaScript:timedRefresh(50000);">
<div id="myDiv"></div>
</body>
I want to refresh the page/load the XML every 5 seconds however the above code does not appear to work. I have read (http://www.htmlgoodies.com/tutorials/getting_started/article.php/3479551/Reloading-The-Page.htm) that you can use META tags ()to refresh the page as well.
Any help to get this code working would be greatly appreciated.
ANSWER
Change the code to the below -
window.onload = startInterval();
function startInterval()
{
setInterval("loadXMLDoc();", 5000);
}