function ajax(object){
var url = object.url || "";
if(!url) return;
var method = object.method || "GET";
var data = object.data || null;
var handler = object.handler || function(){};
var xmlHttp;
var data;
if(window.XMLHttpRequest){
xmlHttp = new window.XMLHttpRequest();
}else if(window.ActiveXObject){
xmlHttp = new window.ActiveXObject("Microsoft.XMLHTTP");
}
xmlHttp.open(method,url,true);
xmlHttp.send(data);
xmlHttp.onreadystatechange = function(){
if(xmlHttp.readyState == 4){
if(xmlHttp.status ==0 || xmlHttp.status == 200){
if(xmlHttp.responseXML){
data = xmlHttp.responseXML;
}else{
if(window.JSON&&window.JSON.parse){
data = window.JSON.parse(xmlHttp.responseText);
}else{
data = eval("("+xmlHttp.responseText+")")
}
}
handler(data);
}else{
showMsg("系统繁忙,请稍后再试。");
}
}
}
}
调用此方法就可以!传入请求路径,自己处理回调函数!全部是自己手写!原始的ajax请求,望采纳!