X-Git-Url: http://git.asbjorn.biz/?a=blobdiff_plain;f=src%2Ftransports%2Fscript.js;h=4f55dc5ad802aea873db81fcdd5b74300e9bc581;hb=22e28b01e60e87b2454f88ca128fb84916b13564;hp=fe3873557143b23702be098580d38fc67bf7c36f;hpb=3c641bd1345aa25489fc16f09d5f4709bf05b09b;p=jquery.git diff --git a/src/transports/script.js b/src/transports/script.js index fe38735..4f55dc5 100644 --- a/src/transports/script.js +++ b/src/transports/script.js @@ -12,12 +12,12 @@ jQuery.extend( true, jQuery.ajaxSettings , { }, dataConverters: { - "text => script": jQuery.globalEval + "text script": jQuery.globalEval } } ); // Bind script tag hack transport -jQuery.xhr.bindTransport("script", function(s) { +jQuery.xhr.transport("script", function(s) { // Handle cache special case if ( s.cache === undefined ) { @@ -47,10 +47,9 @@ jQuery.xhr.bindTransport("script", function(s) { script.src = s.url; // Attach handlers for all browsers - script.onload = script.onreadystatechange = function(statusText) { + script.onload = script.onreadystatechange = function( _ , statusText) { - if ( (!script.readyState || - script.readyState === "loaded" || script.readyState === "complete") ) { + if ( ! script.readyState || /loaded|complete/.test( script.readyState ) ) { // Handle memory leak in IE script.onload = script.onreadystatechange = null; @@ -60,10 +59,10 @@ jQuery.xhr.bindTransport("script", function(s) { head.removeChild( script ); } - script = undefined; + script = 0; - // Callback & dereference - callback(statusText ? 0 : 200, statusText || "success"); + // Callback + callback( statusText ? 0 : 200, statusText || "success" ); } }; // Use insertBefore instead of appendChild to circumvent an IE6 bug. @@ -73,7 +72,7 @@ jQuery.xhr.bindTransport("script", function(s) { abort: function(statusText) { if ( script ) { - script.onload(statusText); + script.onload( 0 , statusText ); } } };