IE下显示正正常,其它浏览器显示XMLHttpRequest.responseXML为undefined

<br> function createXmlHttpRequest() {<br> // if (window.ActiveXObject) {//如果是IE浏览器<br> return new ActiveXObject(&quot;Microsoft.XMLHTTP&quot;); //此对象在IE中显示返回XML值正常<br> // }<br> // else if (window.XMLHttpRequest) {//非IE浏览器<br> // return new XMLHttpRequest();<br> // }<br> }</p> <pre><code> function getUser(loginId) { if (loginId != &quot;&quot;) { //请求字符串 var url = &quot;AjaxService/GetUser.ashx?loginId=&quot; + loginId; //1.创建XMLHttpRequest组件 xhr = createXmlHttpRequest(); //2.设置回调函数 xhr.onreadystatechange = function () { if (xhr.readyState == 4 &amp;&amp; xhr.status == 200) { var dom = xhr.responseXML; //得到XMLDocument对象 // var xmlNode = dom.getElementsByTagName(&quot;Name&quot;); // var textNode = xmlNode[0]; // var xmlText = textNode.nodeValue; document.getElementById(&quot;Name&quot;).innerHTML =dom.getElementsByTagName(&quot;Name&quot;)[0].text;//dom.nodes.item(0).childNodes.item(0).text;// document.getElementById(&quot;Address&quot;).innerHTML = dom.getElementsByTagName(&quot;Address&quot;)[0].text; document.getElementById(&quot;Phone&quot;).innerHTML = dom.getElementsByTagName(&quot;Phone&quot;)[0].text; document.getElementById(&quot;Mail&quot;).innerHTML = dom.getElementsByTagName(&quot;Mail&quot;)[0].text; document.getElementById(&quot;userinfo&quot;).style.display = &quot;&quot;; //div显示 } } //3.初始化XMLHttpRequest组件 xhr.open(&quot;GET&quot;, url, true); xhr.send(null); } } </code></pre>

web开发你能不能用Jquery来屏蔽那些兼容性问题。

这个本来就是IE对象,其他浏览器有其他类