兼容各个浏览器的CORS
function createCORSRequest(method,url){
var xhr = new XMLHttpRequest();
if("withCreadetials" in xhr){
xhr.open(method,url,true);
}else if(type ofXDomainRequest!="undefined"){
xhr=new XDomainRequest();
xhr.open(method,url);
}else{
xhr=null;
}
return xhr;
}
var request=createCORSRequest("get","http://somewhere.com/page/")
if(request){
request.οnlοad=function(){
//responseText处理
};
request.send();
}
//可用onerror事件检测错误