3 // Install script dataType
6 script: "text/javascript, application/javascript, application/ecmascript, application/x-ecmascript"
9 script: /javascript|ecmascript/
12 "text script": function( text ) {
13 jQuery.globalEval( text );
19 // Handle cache's special case and global
20 jQuery.ajaxPrefilter( "script", function( s ) {
21 if ( s.cache === undefined ) {
24 if ( s.crossDomain ) {
30 // Bind script tag hack transport
31 jQuery.ajaxTransport( "script", function(s) {
33 // This transport primarily deals with cross domain requests
34 // but also sameDomain request within file:// due to
35 // http://code.google.com/p/chromium/issues/detail?id=4197 + 47416
36 var local = location.protocol === 'file:';
37 if ( s.crossDomain || local ) {
40 head = document.head || document.getElementsByTagName( "head" )[0] || document.documentElement;
44 send: function( _, callback ) {
46 script = document.createElement( "script" );
48 script.async = "async";
50 if ( s.scriptCharset ) {
51 script.charset = s.scriptCharset;
56 // Attach handlers for all browsers
57 script.onload = script.onreadystatechange = function( _, isAbort ) {
59 if ( !script.readyState || /loaded|complete/.test( script.readyState ) ) {
61 // Handle memory leak in IE
62 script.onload = script.onreadystatechange = null;
65 if ( head && script.parentNode ) {
66 head.removeChild( script );
69 // Dereference the script
72 // Callback if not abort
74 callback( 200, "success" );
78 // Use insertBefore instead of appendChild to circumvent an IE6 bug.
79 // This arises when a base node is used (#2709 and #4378).
80 head.insertBefore( script, head.firstChild );
85 script.onload( 0, 1 );