I am looking to call an ajax function periodically. Below is my code and this is not serving purpose at the moment. Could any one help if I placing the window.setTimeout() stmnt properly..
<script>
var xmlhttp;
function loadXMLDoc(url, cfunc)
{
var config='${config}';
if (window.XMLHttpRequest)
{
xmlhttp=new XMLHttpRequest();
}
else
{
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange=cfunc;
xmlhttp.open("GET",url+config,true);
xmlhttp.send();
}
window.onload=ajaxFunction1();
function ajaxFunction1()
{
loadXMLDoc("TagDataRetrieval?config=",function()
{
if (xmlhttp.readyState==4 && xmlhttp.status==200)
{
document.getElementById("myDiv1").innerHTML=xmlhttp.responseText;
}
});
window.setTimeout("ajaxFunction1()", 5000);
}
</script>
1 Answer