js判断服务器上的文件是否存在

名人名言:每个人在他生活中都经历过不幸和痛苦。有些人在苦难中只想到自己,他就悲观消极发出绝望的哀号;有些人在苦难中还想到别人,想到集体,想到祖先和子孙,想到祖国和全人类,他就得到乐观和自信。——洗星海


js判断服务器上的文件是否存在(ajax)



function IsExistsFile(filepath)
        {
            var xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
            xmlhttp.open("GET",filepath,false);
            xmlhttp.send();
            if(xmlhttp.readyState==4){  
                if(xmlhttp.status==200) return true; //url存在  
                else if(xmlhttp.status==404) return false; //url不存在  
                else return false;//其他状态  
            }
        }
原文地址:https://www.cnblogs.com/peaceshow/p/2631007.html