永远不会调用 jQuery getScript 失败函数。看到这个小提琴:http: //jsfiddle.net/getsetbro/8xNMs/
$.getScript("http://api.jquery.com/scripts/jquery.NO-SUCH-FILE.js").done(function() {
console.log('yep');
}).fail(function() {
console.log('fail function does not fire fine');
});
并且永远不会调用完整的功能:http: //jsfiddle.net/getsetbro/ns6yQ/
$.ajax({
url: url,
type: 'get',
crossDomain: true,
dataType: 'script',
async:false,
cache:false,
success: function(result) {
console.log('SUCCESS');
},
error: function(result) {
console.log('ERROR');
},
complete: function(result) {
console.log('COMPLETE');
}
})
哦,在 IE 中,当它应该失败时,它实际上会触发 SUCCESS 和 COMPLETE。=[