jquery getScript函数永远不会失败?

get*_*bro 3 ajax jquery getscript

永远不会调用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');
});
Run Code Online (Sandbox Code Playgroud)

并且永远不会调用完整的函数: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');
    }
})
Run Code Online (Sandbox Code Playgroud)

哦,在IE中它实际上会触发SUCCESS和COMPLETE它应该失败.= [

Yur*_*nko 10

.fail 不适用于跨域请求.

// Bind script tag hack transport
jQuery.ajaxTransport( "script", function(s) {

    // This transport only deals with cross domain requests
    if ( s.crossDomain ) {
    ...
    script = document.createElement( "script" );
Run Code Online (Sandbox Code Playgroud)

脚本元素不会触发错误等.

但它适用于同一个域名.http://jsfiddle.net/8xNMs/2/