您的位置:程序门 -> java -> j2se / 基础类



ajax...用firefox正常,ie不正常


[收藏此页] [打印本页]选择字色:背景色:字体:[][][]


ajax...用firefox正常,ie不正常
发表于:2007-05-04 11:50:17 楼主
源码如下:
var   http_request=false;
    function   send_request(url){//初始化,指定处理函数,发送请求的函数
        http_request=false;
//开始初始化xmlhttprequest对象
if(window.xmlhttprequest){//mozilla浏览器
  http_request=new   xmlhttprequest();
  if(http_request.overridemimetype){//设置mime类别
      http_request.overridemimetype( "text/xml ");
  }
}
else   if(window.activexobject){//ie浏览器
  try{
    http_request=new   activexobject( "msxml2.xmlhttp ");
  }catch(e){
    try{
    http_request=new   activexobject( "microsoft.xmlhttp ");
    }catch(e){}
  }
        }
if(!http_request){//异常,创建对象实例失败
  window.alert( "创建xmlhttp对象失败! ");
  return   false;
}
http_request.onreadystatechange=processrequest;
//确定发送请求方式,url,及是否同步执行下段代码
        http_request.open( "get ",url,true);
http_request.send(null);
    }
    //处理返回信息的函数
    function   processrequest(){
      if(http_request.readystate==4){//判断对象状态
          if(http_request.status==200){//信息已成功返回,开始处理信息
    document.getelementbyid(reobj).innerhtml=http_request.responsetext;
  }
  else{//页面不正常
    alert( "您所请求的页面不正常! ");
  }
      }
    }
    function   getclass(obj){
      var   pid=document.form1.select1.value;
      document.getelementbyid(obj).innerhtml= " <option> loading... </option> ";
      send_request( 'doclass.php?pid= '+pid);
      reobj=obj;
    }
发表于:2007-05-04 19:53:311楼 得分:0
http_request=new   activexobject( "microsoft.xmlhttp ");错了吧

http_request=new   activexobject( "microsoft.xmlhttp ");
发表于:2007-05-09 18:07:272楼 得分:0
我改了,可是还是不行啊.....救命~
发表于:2007-05-10 00:09:203楼 得分:0
ajax那边没人回答,现在转个热门地点   呵呵
发表于:2007-05-10 08:55:104楼 得分:0
var   http   =   gethttpobject();
function   gethttpobject(){
var   xmlhttp   =   false;
if(window.xmlhttprequest){
xmlhttp   =   new   xmlhttprequest();
if(xmlhttp.overridemimetype){
xmlhttp.overridemimetype( 'text/xml ');
  }
}
else{
try{
xmlhttp   =   new   activexobject( "msxml2.xmlhttp ");
}catch(e){
try{
xmlhttp   =   new   activexobject( "microsoft.xmlhttp ");
}catch(e){
xmlhttp   =   false;
}
        }
}
return   xmlhttp;
}

把你获得xmlhttp对象换成这个试试
发表于:2007-05-10 08:56:145楼 得分:0
就是你里面获得   http_request对象
发表于:2007-05-12 00:37:176楼 得分:0
不知道是我不行,还是上面的代码也不行?哈哈哈哈
发表于:2007-05-12 09:26:117楼 得分:0
else   if(window.activexobject){//ie浏览器
try{
http_request=new   activexobject( "msxml2.xmlhttp ");
}catch(e){
try{
http_request=new   activexobject( "microsoft.xmlhttp ");
}catch(e){}
}
改成这样试试:
else   if(window.activexobject)
{
http_request=new   activexobject( "microsoft.xmlhttp ");
}
发表于:2007-05-13 00:09:108楼 得分:0
还是不行!
高手怎么还没现身?
^_^......


快速检索

最新资讯
热门点击