OSDN Git Service

new repo
[bytom/vapor.git] / tools / side_chain_tool / web / node_modules / jquery / src / ajax / script.js
1 define( [
2         "../core",
3         "../var/document",
4         "../ajax"
5 ], function( jQuery, document ) {
6
7 "use strict";
8
9 // Prevent auto-execution of scripts when no explicit dataType was provided (See gh-2432)
10 jQuery.ajaxPrefilter( function( s ) {
11         if ( s.crossDomain ) {
12                 s.contents.script = false;
13         }
14 } );
15
16 // Install script dataType
17 jQuery.ajaxSetup( {
18         accepts: {
19                 script: "text/javascript, application/javascript, " +
20                         "application/ecmascript, application/x-ecmascript"
21         },
22         contents: {
23                 script: /\b(?:java|ecma)script\b/
24         },
25         converters: {
26                 "text script": function( text ) {
27                         jQuery.globalEval( text );
28                         return text;
29                 }
30         }
31 } );
32
33 // Handle cache's special case and crossDomain
34 jQuery.ajaxPrefilter( "script", function( s ) {
35         if ( s.cache === undefined ) {
36                 s.cache = false;
37         }
38         if ( s.crossDomain ) {
39                 s.type = "GET";
40         }
41 } );
42
43 // Bind script tag hack transport
44 jQuery.ajaxTransport( "script", function( s ) {
45
46         // This transport only deals with cross domain requests
47         if ( s.crossDomain ) {
48                 var script, callback;
49                 return {
50                         send: function( _, complete ) {
51                                 script = jQuery( "<script>" ).prop( {
52                                         charset: s.scriptCharset,
53                                         src: s.url
54                                 } ).on(
55                                         "load error",
56                                         callback = function( evt ) {
57                                                 script.remove();
58                                                 callback = null;
59                                                 if ( evt ) {
60                                                         complete( evt.type === "error" ? 404 : 200, evt.type );
61                                                 }
62                                         }
63                                 );
64
65                                 // Use native DOM manipulation to avoid our domManip AJAX trickery
66                                 document.head.appendChild( script[ 0 ] );
67                         },
68                         abort: function() {
69                                 if ( callback ) {
70                                         callback();
71                                 }
72                         }
73                 };
74         }
75 } );
76
77 } );