js-ajax实现获取xmlHttp对象

Posted DREAM

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了js-ajax实现获取xmlHttp对象相关的知识,希望对你有一定的参考价值。

//获取xmlHttp对象
    function createXMLHttp() {
    
        var xmlHttp;
        //对于大多数浏览器适用
        if (window.XMLHttpRequest()) {
            xmlHttp = new XMLHttpRequest();
        }
        //考虑浏览器的兼容性
        if (window.ActiveXObject) {
            xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
            if (!xmlHttp) {
                xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
            }
        }
        return xmlHttp;
    }

 

以上是关于js-ajax实现获取xmlHttp对象的主要内容,如果未能解决你的问题,请参考以下文章