XMLHttpRequestUtil
//XMLHttpRequest类 function XMLHTTPRequestUtil() { this.Instance = null; this.GetXMLHttpRequest = function () { var r = window.XMLHttpRequest ? new XMLHttpRequest() : window.ActiveXObject ? new ActiveXObject("Microsoft.XMLHTTP") : new XMLHttpRequest(); this.Instance = r; return r; }; this.AjaxRequest = function (callback, urlParam, method, url) { //创建XmlHttpRequest对象 var xmlHttpRequest = this.Instance; if (xmlHttpRequest != null) { //建立POST链接 xmlHttpRequest.open(method, url, true); xmlHttpRequest.onreadystatechange = callback; //设置请求头 xmlHttpRequest.setRequestHeader("Accept", "application/json"); xmlHttpRequest.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); //发送请求 xmlHttpRequest.send(urlParam); } } }