I have an Interval set to run a function every 3 seconds.
intervalStepper = window.setInterval('intervalTick()','3000');
function intervalTick() {
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) {
gotResult(xmlhttp.responseText);
}
}
xmlhttp.open('GET','index.php?ajax=true',true);
xmlhttp.send();
}
function gotResult(res) {
alert(res);
}
Additionally, I have another Ajax call which is triggered by a button click.
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) {
agentDetailGotten(xmlhttp.responseText);
}
}
xmlhttp.open('GET','index.php?anotherPage=true',true);
xmlhttp.send();
When the second code executes at the same time as the interval tick and first call, it seems like the interval stops. Is this a known issue or am I missing something major?
Thank you for your assistance!