这篇文章主要介绍了javascript创建createXmlHttpRequest对象的示例代码。需要的朋友可以过来参考下,希望对大家有所帮助
代码如下: var xmlHttp; function createXmlHttpRequest() { if(window.XMLHttpRequest) { xmlHttp=new XMLHttpRequest(); if(xmlHttp.overrideMimeType) { xmlHttp.overrideMimeType("text/xml"); } } else if(window.ActiveXObject) { try { xmlHttp=new ActiveXObject("Msxml2.XMLHTTP"); } catch(e) { xmlHttp=new ActiveXObject("Microsoft.XMLHTTP"); } } if(!xmlHttp) { window.alert("你的浏览器不支持创建XMLhttpRequest对象"); } return xmlHttp; }