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;
    }

 

posted @ 2016-11-08 15:30  DREAM_SF  阅读(558)  评论(0编辑  收藏  举报