X-Git-Url: http://git.asbjorn.biz/?a=blobdiff_plain;f=src%2Fajax%2Fscript.js;h=8e2e89ac5541c68dba5035a3ab458eb71fbedee3;hb=a8fa5f2ec1030bceb9a65d0237f0c92ae4e014dd;hp=75f34fce20b6bc753b6a79f937fd6173e0e8e9db;hpb=e221d39e981ceac030d2e0431570742fb51337d5;p=jquery.git diff --git a/src/ajax/script.js b/src/ajax/script.js index 75f34fc..8e2e89a 100644 --- a/src/ajax/script.js +++ b/src/ajax/script.js @@ -14,10 +14,9 @@ jQuery.ajaxSetup({ converters: { "text script": jQuery.globalEval } -}); // Bind script tag hack transport -jQuery.ajax.transport("script", function(s) { +}).ajaxTransport("script", function(s) { // Handle cache special case if ( s.cache === undefined ) { @@ -47,7 +46,7 @@ jQuery.ajax.transport("script", function(s) { script.src = s.url; // Attach handlers for all browsers - script.onload = script.onreadystatechange = function( _ , statusText) { + script.onload = script.onreadystatechange = function( _ , isAbort ) { if ( ! script.readyState || /loaded|complete/.test( script.readyState ) ) { @@ -59,10 +58,13 @@ jQuery.ajax.transport("script", function(s) { head.removeChild( script ); } + // Dereference the script script = 0; - // Callback - callback( statusText ? 0 : 200, statusText || "success" ); + // Callback if not abort + if ( ! isAbort ) { + callback( 200, "success" ); + } } }; // Use insertBefore instead of appendChild to circumvent an IE6 bug. @@ -70,9 +72,9 @@ jQuery.ajax.transport("script", function(s) { head.insertBefore( script, head.firstChild ); }, - abort: function(statusText) { + abort: function() { if ( script ) { - script.onload( 0 , statusText ); + script.onload(0,1); } } };