//创建ajax对象
function getXHR(){
if(window.XMLHttpRequest){
return new XMLHttpRequest();
}else{
return new ActiveXObject("Microsoft.XMLHTTP");
}
}
//校验文件是否加载成功
//path为文件路径
function isHasFile(path){
var xhr = getXHR();
xhr.open("GET",path,false);
xhr.send();
if(xhr.status == 200){
alert("文件加载成功");
return true;
}else{
alert("文件加载失败");
return false;
}
}