更新同一页面不同div内容的问题
erldy 2007-03-07 12:08:30 var xmlHttp;
function creatXMLHttpRequest() {
if(window.ActiveXObject) {
xmlHttp = new ActiveXObject('Microsoft.XMLHTTP');
} else if(window.XMLHttpRequest) {
xmlHttp = new XMLHttpRequest();
}
}
function startRequest(type,result) {
var queryString="";
//var domain = document.getElementById('domain').value;
queryString = "type=" + type;
creatXMLHttpRequest();
xmlHttp.open("GET","news.php?action=GetNews&"+queryString+"×tamp=" + new Date().getTime(),"true");
xmlHttp.onreadystatechange = handleStateChange;
//xmlHttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded;");
xmlHttp.send(null);
function handleStateChange() {
if(xmlHttp.readyState == 1) {
document.getElementById(result).style.cssText = "";
document.getElementById(result).innerHTML = "正导入数据...";
}
if(xmlHttp.readyState == 4) {
if(xmlHttp.status == 200) {
document.getElementById(result).style.cssText = "";
var allcon = xmlHttp.responseText;
document.getElementById(result).innerHTML = allcon;
}
}
}
}
通过上面代码更新同一页面的DIV:
<div align="left" id="nresult1"><script language="JavaScript">startRequest('XXXX','nresult1');</script></div>
<div align="left" id="nresult2"><script language="JavaScript">startRequest('ZZZZ','nresult2');</script></div>
但是出现的结果有时候是第一个DIV一直显示“正导入数据..”,第二个DIV正常,或者第一个DIV显示的跟第二个DIV一样的内容(本来应该是不一样的),到底是哪里的问题呢?多谢指教!!