我需要检查一堆脚本的存在。目前,我在控制台中多次收到这条线,我想避免这种情况:
GET http://localhost:8888/js/flaw/blahblah.js 404 (Not Found)
我当前的设置(我刚刚添加了 try catch 作为尝试,但它不起作用。)
var filesThatExist = [];
var filesThatDont = [];
function loadScript(path) {
try {
$.ajax(path)
.done(function(){
filesThatExist.push(path);
})
.fail(function(){
filesThatDont.push(path);
});
} catch (e) {
}
}