前几天, 做公司的一个统计表, 用ajax写的, 在我本机上测试通过, 没问题, 让我同事看时, 却加载不上去,到网上查了一下,也没结果, 过了这些天, 再到网上找寻同样的问题的答案 呵呵, 搜到了

解决办法: 原因是IE7.0比IE6.0多了本地XMLHTTP支持。

所以解决方法就是:点击“工具”->“Internet选项”->“高级”,在“安全”节点下找到“启用本机XMLHTTP支持”,该选项默认是钩选,禁用它后可以了。

这个方法, 行是行, 可以要改客户端的IE设置, 很是麻烦的, 所以下面的方法也许更好一些:

将我原来的这段代码: (创建xml对像的代码)

{
    xmlhttpobj = false;
    try{//创建对象,一个一个的试,哎,要是能统一标准都好。。
        xmlhttpobj = new XMLHttpRequest;
    }catch(e){
        try{
            xmlhttpobj=new ActiveXObject("MSXML2.XMLHTTP");
        }catch(e2){
            try{
                xmlhttpobj=new ActiveXObject("Microsoft.XMLHTTP");
            }catch(e3){
                xmlhttpobj = false;
            }
        }
    }
    return xmlhttpobj;
}

改为:

function createxmlhttp() {
   var xmlhttpobj;
   if (window.ActiveXObject) {
   try {
      xmlhttpobj=new window.ActiveXObject("Msxml2.XMLHTTP");
   } catch (e) {
      try {
        xmlhttpobj=new window.ActiveXObject("Microsoft.XMLHTTP");
      } catch (E) {
        alert("不能创建XMLHttpRequest实例!");
        return false;
      }     
   }    
   } else if (window.XMLHttpRequest) {
      xmlhttpobj=new window.XMLHttpRequest();
      if (xmlhttpobj.overrideMimeType) {
         xmlhttpobj.overrideMimeType("text/xml");
      }
   }
   return xmlhttpobj;
}

 

就可以了, 具体为什么是这样的, 请各个高手留言讨论一下......

这个问题解决了, 接着来的就是XmlHttp的onreadystatechange只能生效一次

因而, 所有的链接只能在第一次点击时生效, 可以是向同一链接发送了一个null值的结果吧,

解决办法:

function getuser(department){

if(department==0){
   document.getElementById("userlist").innerHTML="没有信息!";
   return;
};
var xmlhttpobj = createxmlhttp();
if(xmlhttpobj){//如果创建对象xmlhttpobj成功
// xmlhttpobj.open('get',"usertest.asp?department="+bigclassid+"&number="+Math.random(),true);//get方法 加个随机数。
   var url="userajax.asp?department="+department+"&action=query&number="+Math.random() //这里加入一个随机的值就可以解决问题了
   xmlhttpobj.open('get',url,true); //get方法

   xmlhttpobj.send(null);
   //alert(department);
   xmlhttpobj.onreadystatechange=function(){//客户端监控函数
  
    if(xmlhttpobj.readystate==4){//服务器处理请求完成
   
     if(xmlhttpobj.status==200){
      //alert(xmlhttpobj.responseText); '对话框, 做测试用的!
      var html = xmlhttpobj.responseText;//获得返回值
      document.getElementById("userlist").innerHTML=html;
     }else{
      document.getElementById("userlist").innerHTML="对不起,您请求的页面有问题...";
     }
    }else{
     document.getElementById("userlist").innerHTML="加载中,请梢候...";//服务器处理中
    }
   }
}
}

不管用了多长时间, 问题还是解决了, 真是一波三折啊.....在IE7.0上不能浏览AJAX的网页的解决方法 - 末日博士 - 郁郁葱葱