怎样判断ajax读取完毕 等ajax高手来 ajax读取 一程序里面有大片 mysql 和一个模板有的时候读取很慢 造成读取不完全 使得加载进来的页面混乱有没有什么办法能够判断ajax读取完毕后在输出到浏览器 如果没有全部读取完毕则不加载 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 onreadystatechange指定当readyState属性改变时的事件处理句柄语法oXMLHttpRequest.onreadystatechange = funcMyHandler;Example如下的例子演示当XMLHTTPRequest对象的readyState属性改变时调用HandleStateChange函数,当数据接收完毕后(readystate == 4)此页面上的一个按钮将被激活var xmlhttp=null;function PostOrder(xmldoc){ var xmlhttp = new ActiveXObject("Msxml2.XMLHTTP.5.0"); xmlhttp.Open("POST", "http://myserver/orders/processorder.asp", false); xmlhttp.onreadystatechange= HandleStateChange; xmlhttp.Send(xmldoc); myButton.disabled = true;}function HandleStateChange(){ if (xmlhttp.readyState == 4) { myButton.disabled = false; alert("Result = " + xmlhttp.responseXML.xml); }} function creatXHR(){ if (window.ActiveXObject) return new window.ActiveXObject('Microsoft.XMLHTTP'); else if (window.XMLHttpRequest) return new window.XMLHttpRequest(); else return null;}var xhr = creatXHR();xhr.open('GET', 'xml.xml');xhr.onreadystatechange = function(){ if (xhr.readyState == 4 && xhr.status == 200) { // 这里是最后正确完成后执行的 alert(xhr.responseText); }}xhr.send(null); readyState == 4 && readyState == 200 用2楼的方法吧,但我觉得应该进一步处理下. if(xmlhttp.readyState == 4) //状态可用 { if(xmlhttp.status == 200) { backfun(xmlhttp.responseText);//返回文本 } else { alert("错误代码:"+xmlhttp.status); backfun(null); } } 使用javascript如何在客户端创建一个文件夹呢 settimeout和jquery的animate一起使用时的问题 javascript js显示数据库里数据 js如何在指定id 生成html代码呢? addInstanceRow 问题 如何用JS递归一个目录下所有子目录(文件不用)。 求一個onClick時、图片切換的函数 一个很怪的问题 为什么加了form就不行了!??? 如何不让js文件取缓存的 关于loading怎么弄
语法oXMLHttpRequest.onreadystatechange = funcMyHandler;Example如下的例子演示当XMLHTTPRequest对象的readyState属性改变时调用HandleStateChange函数,当数据接收完毕后(readystate == 4)此页面上的一个按钮将被激活var xmlhttp=null;
function PostOrder(xmldoc)
{
var xmlhttp = new ActiveXObject("Msxml2.XMLHTTP.5.0");
xmlhttp.Open("POST", "http://myserver/orders/processorder.asp", false);
xmlhttp.onreadystatechange= HandleStateChange;
xmlhttp.Send(xmldoc);
myButton.disabled = true;
}
function HandleStateChange()
{
if (xmlhttp.readyState == 4)
{
myButton.disabled = false;
alert("Result = " + xmlhttp.responseXML.xml);
}
}
function creatXHR(){
if (window.ActiveXObject) return new window.ActiveXObject('Microsoft.XMLHTTP');
else if (window.XMLHttpRequest) return new window.XMLHttpRequest();
else return null;
}var xhr = creatXHR();
xhr.open('GET', 'xml.xml');
xhr.onreadystatechange = function(){
if (xhr.readyState == 4 && xhr.status == 200) {
// 这里是最后正确完成后执行的
alert(xhr.responseText);
}
}
xhr.send(null);
if(xmlhttp.readyState == 4) //状态可用
{ if(xmlhttp.status == 200)
{
backfun(xmlhttp.responseText);//返回文本
}
else
{ alert("错误代码:"+xmlhttp.status);
backfun(null);
}
}