你好,我目前正在进行一项xmhhttp请求,但网站需要一些时间才能加载,所以我只能得到ReadyState = 3和status = 200。因此,我需要等待readystate = 4的东西,但我想限制这个功能,使它每秒只检查一次readystate = 4,否则不执行任何操作。
这样的延迟函数应该长什么样?
if (xmlhttp.readyState==4 && xmlhttp.status==200)//Add the delay here so that the else doesn't occur
{
var txt=xmlhttp.responseText;
.....
else {
document.write("status: " + xmlhttp.readyState + " " + xmlhttp.status);
}