这段代码有点不明白......
IPOz 2003-10-09 04:57:35 function check_alarm()
{
var xmlHttp = XmlHttp.create();
xmlHttp.open("GET", "/omnet-web/monitorservlet?do=new", true);
xmlHttp.onreadystatechange = function () {
if (xmlHttp.readyState == 4) {
if(xmlHttp.responseText == "1") {
flag.style.visibility = "visible";
}
else {
flag.style.visibility = "hidden";
}
setTimeout("check_alarm()",1000);
}
};
// call in new thread to allow ui to update
window.setTimeout(function () {
xmlHttp.send(null);
}, 10);
}
xmlHttp.responseText一直都是"0"(其实服务器已经是"1"),但如果注释掉
window.setTimeout(function () {
xmlHttp.send(null);
}, 10);
xmlHttp.responseText将很快为“1”,但check_alarm()只能调用一次,即setTimeout()好象不起作用?!
请大家解释一下这段代码,谢谢!