本文介绍了我在使用ajax打开方法的Internet Explorer中遇到问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

下面的代码在Internet Explorer浏览器中引发错误.

Below code throws error in Internet Explorer browser.

function createRequestObject()
{var tmpXmlt;
   if (window.XMLHttpRequest) {
       // Mozilla, Safari would use this method ...
       tmpXmlt = new XMLHttpRequest();
   } else if (window.ActiveXObject) {
      // IE would use this method ...
      try { tmpXmlt= new ActiveXObject("Msxml2.XMLHTTP.6.0"); }
      catch (e1) {}
      try { tmpXmlt=new ActiveXObject("MSXML2.XMLHTTP.3.0"); }
      catch (e2) {}
      try { tmpXmlt= new ActiveXObject("Msxml2.XMLHTTP"); }
      catch (e3) {}
      //Microsoft.XMLHTTP points to Msxml2.XMLHTTP.3.0 and is redundant
     throw new Error("This browser does not support XMLHttpRequest.");
  }
return(tmpXmlt);
}

var xmlhttp = createRequestObject();

function makeGetRequest() {
    xmlhttp.open(''get'', ''data.xml'',false);
    xmlhttp.onreadystatechange = processResponse;
    xmlhttp.send(null);
}

推荐答案


这篇关于我在使用ajax打开方法的Internet Explorer中遇到问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-27 11:39