X-Git-Url: http://git.asbjorn.it/?a=blobdiff_plain;f=src%2Fajax%2Fscript.js;h=91c84d6f41d540ab96e171012ffa0aa59d258126;hb=85a195c6d5ad6fccf9dd3df40ebecc338325d461;hp=bdf69dd8b20f66e24ed62317b7d540e51bbabed1;hpb=64e1cdbb95b8bbefbc9dec70ae30e0714a549619;p=jquery.git diff --git a/src/ajax/script.js b/src/ajax/script.js index bdf69dd..91c84d6 100644 --- a/src/ajax/script.js +++ b/src/ajax/script.js @@ -2,47 +2,45 @@ // Install script dataType jQuery.ajaxSetup({ - accepts: { script: "text/javascript, application/javascript" }, - contents: { script: /javascript/ }, - converters: { - "text script": jQuery.globalEval + "text script": function( text ) { + jQuery.globalEval( text ); + return text; + } } }); // Handle cache's special case and global -jQuery.ajaxPrefilter("script", function(s) { - +jQuery.ajaxPrefilter( "script", function( s ) { if ( s.cache === undefined ) { s.cache = false; } - if ( s.crossDomain ) { s.type = "GET"; s.global = false; } -}); +} ); // Bind script tag hack transport -jQuery.ajaxTransport("script", function(s) { +jQuery.ajaxTransport( "script", function(s) { // This transport only deals with cross domain requests if ( s.crossDomain ) { var script, - head = document.getElementsByTagName("head")[0] || document.documentElement; + head = document.getElementsByTagName( "head" )[ 0 ] || document.documentElement; return { - send: function(_, callback) { + send: function( _, callback ) { - script = document.createElement("script"); + script = document.createElement( "script" ); script.async = "async"; @@ -53,9 +51,9 @@ jQuery.ajaxTransport("script", function(s) { script.src = s.url; // Attach handlers for all browsers - script.onload = script.onreadystatechange = function( _ , isAbort ) { + script.onload = script.onreadystatechange = function( _, isAbort ) { - if ( ! script.readyState || /loaded|complete/.test( script.readyState ) ) { + if ( !script.readyState || /loaded|complete/.test( script.readyState ) ) { // Handle memory leak in IE script.onload = script.onreadystatechange = null; @@ -66,10 +64,10 @@ jQuery.ajaxTransport("script", function(s) { } // Dereference the script - script = 0; + script = undefined; // Callback if not abort - if ( ! isAbort ) { + if ( !isAbort ) { callback( 200, "success" ); } } @@ -81,11 +79,11 @@ jQuery.ajaxTransport("script", function(s) { abort: function() { if ( script ) { - script.onload(0,1); + script.onload( 0, 1 ); } } }; } -}); +} ); })( jQuery );