当前位置:编程学习 > JAVA >>

ajax方法

[javascript] 
var Ajax = (function () { 
    //XMLHttpRequest对象 
    var _xMLHttpRequest = null, 
            _funData = {/*私有方法所需的全局变量*/ 
                readyState: 1 
            }, 
            _fun = {/*私有方法*/ 
                sendArguments: function (d) { 
                    if (typeof d === "object" && d != null) { 
                        var _d = []; 
                        for (var i in d) { 
                            _d.push(encodeURIComponent(i) + "=" + encodeURIComponent(d[i])); 
                        } 
                        return _d.join('&'); 
                    } 
                    return null; 
                }, 
                createXMLHttpRequest: function () {/*创建XMLHttpRequest*/ 
                    if (!_xMLHttpRequest) { 
                        if (XMLHttpRequest) { 
                            _xMLHttpRequest = new XMLHttpRequest(); 
                        } 
                        else { 
                            if (ActiveXObject) { 
                                try { 
                                    _xMLHttpRequest = new ActiveXObject("Msxm12.XMLHTTP"); 
                                } 
                                catch (e) { 
                                    _xMLHttpRequest = new ActiveXObject("Microsoft.XMLHTTP"); 
                                } 
                            } 
                        } 
                        return _xMLHttpRequest; 
                    } 
                    else { 
                        _fun.createXMLHttpRequest = function () { 
                            return _xMLHttpRequest; 
                        } 
                    } 
 
                }, 
                extend: function () {/*递归合并对象*/ 
                    var i = arguments.length; 
                    if (i > 0 || typeof arguments[0] !== "object") { 
                        var _o = {}, 
                        j = 1; 
                        for (; j < i; j++) { 
                            if (typeof arguments[j] === "object") { 
                                for (var _i in arguments[j]) { 
                               &

补充:web前端 , JavaScript ,
CopyRight © 2022 站长资源库 编程知识问答 zzzyk.com All Rights Reserved
部分文章来自网络,