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;//其他状态  
            }
        }

posted on 2010-06-24 11:46  bicabo  阅读(1551)  评论(0编辑  收藏  举报

导航