window.ajax = function(data){
var type = data.type, url = data.url;
var request = false;
var result;
try {
request = new XMLHttpRequest();
} catch (trymicrosoft) {
try {
request = new ActiveXObject("Msxml2.XMLHTTP");
} catch (othermicrosoft) {
try {
request = new ActiveXObject("Microsoft.XMLHTTP");
} catch (failed) {
request = false;
}
}
};
if (!request) result = "ajax Config Error!";
request.open(type, url, true);
request.onreadystatechange = callBack;
request.send(null);
function callBack(){
if( request.readyState == 4 && request.status == 200 ){
result = request.responseText;
alert(result);
}else{
if(request.readyState == 4){
result = "Error";
return false;
}
}
};
return result;
}
ajax请求
最新推荐文章于 2022-10-29 12:43:10 发布