js-ajax实现获取xmlHttp对象

//获取xmlHttp对象
    function createXMLHttp() {
        var xmlhttp;
        //对于大多数浏览器适用
        if (window.XMLHttpRequest) {
            xmlhttp = new XMLHttpRequest();
        } else {
            //考虑浏览器的兼容性
            xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
            if (!xmlhttp) {
                xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
            }
        }
        return xmlhttp;
    }
原文地址:https://www.cnblogs.com/save-shengfei/p/6043250.html