Js Get 检测是否404

$.get( "http://img12.360buyimg.com/n1/jfs/t1/207023/2/4302/290376/61613c6eEc2e68f8b/51c92e09054c4001.jpg", function() {
debugger;alert( "success" );
})
.done(function() {
debugger;alert( "second success" );
})
.fail(function(rsp) {
debugger;if(rsp.status==404)alert( "error" );
});

PS: 如果 进入 fail 则不会进入 done

如果 成功则会进入done

 

成功完成请求

 

 

 

posted on 2021-10-25 17:20  wakaka_wka  阅读(243)  评论(0编辑  收藏  举报