for(i=0;i<2;i++)
{
var xmlhttp;
if(window.XMLHttpRequest){
//非IE
xmlhttp=new XMLHttpRequest();
}else if(window.ActiveXObject){
try{
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}catch(e){
xmlhttp= new ActiveXObject("Msxml2.XMLHTTP");
}
}
xmlhttp.onreadystatechange=function(){
if(4==xmlhttp.readystate){
if(200==xmlhttp.status){
showData;//在页面显示数据 在不同的DIV中
}
xmlhttp.open("post","URL",false);
//设定http头
xmlhttp.setRequestHeader("Content-type","application/x-www-form-urlencoded");
//发送请求
xmlhttp.send(null);
}理论上来讲 应该先后 2次 显示数据,但现在一次把2次数据都同时显示我看了很多帖子 说是假死造成的。但没有有效的解决方案!
我必须用同步。或者用异步的话,2次ajax 必须有先后顺序(就是必须第一个完成后才可以执行第二个)
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货