更新同一页面不同div内容的问题
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一样的内容(本来应该是不一样的),到底是哪里的问题呢?多谢指教!!
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一样的内容(本来应该是不一样的),到底是哪里的问题呢?多谢指教!!
...全文
相关推荐
用DIV仿iframe框架布局效果
用DIV仿iframe框架布局效果
可爱的iframe+div
NULL 博文链接:https://xxiongdi.iteye.com/blog/407282
简单的注册页面
简单的注册页面,利用frameset让页面在同一个区域转换
用js控件div的滚动条,让它在内容更新时自动滚到底部的实现方法
下面小编就为大家带来一篇用js控件div的滚动条,让它在内容更新时自动滚到底部的实现方法。小编觉得挺不错的,现在就分享给大家,也给大家做个参考。一起跟随小编过来看看吧
基于Ajax+div的“左边菜单、右边内容”页面效果实现
主要介绍了基于Ajax+div的“左边菜单、右边内容”页面效果实现 的相关资料,非常不错,具有参考借鉴价值,需要的朋友可以参考下


