• 一个简单的Ajax框架

    一个简单的Ajax框架: function $(){ if(arguments.length == 1){ return document.getElementById(arguments[0]); } else if(arguments.length == 2){ return arguments[1].documentElement.getElementsByTagName(arguments[0]); } } function Ajax(){ this.call = call; this.getXMLHttpRequest = getXMLHttpRequest; } function getXMLHttpRequest(){ var req; if (window.XMLHttpRequest) { req = new XMLHttpRequest(); } else if (window.ActiveXObject) { req = new ActiveXObject("Microsoft.XMLHTTP"); } return req; } function call(url, success, failure){ var req = this.getXMLHttpRequest(); req.open("GET", url, true); req.onreadystatechange=function(){ if (req.readyState == 4) { if (req.status == 200) { success(req); } else{ failure(req); } } }; req.send(null); }

    0
    79
    1KB
    2008-12-29
    10
上传资源赚积分or赚钱