summaryrefslogtreecommitdiffstats
path: root/js/vendor/jquery/src/ajax/jsonp.js
diff options
context:
space:
mode:
Diffstat (limited to 'js/vendor/jquery/src/ajax/jsonp.js')
-rw-r--r--js/vendor/jquery/src/ajax/jsonp.js39
1 files changed, 25 insertions, 14 deletions
diff --git a/js/vendor/jquery/src/ajax/jsonp.js b/js/vendor/jquery/src/ajax/jsonp.js
index ff0d53899..666e5d1e6 100644
--- a/js/vendor/jquery/src/ajax/jsonp.js
+++ b/js/vendor/jquery/src/ajax/jsonp.js
@@ -1,4 +1,4 @@
-define([
+define( [
"../core",
"./var/nonce",
"./var/rquery",
@@ -9,14 +9,14 @@ var oldCallbacks = [],
rjsonp = /(=)\?(?=&|$)|\?\?/;
// Default jsonp settings
-jQuery.ajaxSetup({
+jQuery.ajaxSetup( {
jsonp: "callback",
jsonpCallback: function() {
var callback = oldCallbacks.pop() || ( jQuery.expando + "_" + ( nonce++ ) );
this[ callback ] = true;
return callback;
}
-});
+} );
// Detect, normalize options and install callbacks for jsonp requests
jQuery.ajaxPrefilter( "json jsonp", function( s, originalSettings, jqXHR ) {
@@ -24,7 +24,10 @@ jQuery.ajaxPrefilter( "json jsonp", function( s, originalSettings, jqXHR ) {
var callbackName, overwritten, responseContainer,
jsonProp = s.jsonp !== false && ( rjsonp.test( s.url ) ?
"url" :
- typeof s.data === "string" && !( s.contentType || "" ).indexOf("application/x-www-form-urlencoded") && rjsonp.test( s.data ) && "data"
+ typeof s.data === "string" &&
+ ( s.contentType || "" )
+ .indexOf( "application/x-www-form-urlencoded" ) === 0 &&
+ rjsonp.test( s.data ) && "data"
);
// Handle iff the expected data type is "jsonp" or we have a parameter to set
@@ -43,14 +46,14 @@ jQuery.ajaxPrefilter( "json jsonp", function( s, originalSettings, jqXHR ) {
}
// Use data converter to retrieve json after script execution
- s.converters["script json"] = function() {
+ s.converters[ "script json" ] = function() {
if ( !responseContainer ) {
jQuery.error( callbackName + " was not called" );
}
return responseContainer[ 0 ];
};
- // force json dataType
+ // Force json dataType
s.dataTypes[ 0 ] = "json";
// Install callback
@@ -60,16 +63,24 @@ jQuery.ajaxPrefilter( "json jsonp", function( s, originalSettings, jqXHR ) {
};
// Clean-up function (fires after converters)
- jqXHR.always(function() {
- // Restore preexisting value
- window[ callbackName ] = overwritten;
+ jqXHR.always( function() {
+
+ // If previous value didn't exist - remove it
+ if ( overwritten === undefined ) {
+ jQuery( window ).removeProp( callbackName );
+
+ // Otherwise restore preexisting value
+ } else {
+ window[ callbackName ] = overwritten;
+ }
// Save back as free
if ( s[ callbackName ] ) {
- // make sure that re-using the options doesn't screw things around
+
+ // Make sure that re-using the options doesn't screw things around
s.jsonpCallback = originalSettings.jsonpCallback;
- // save the callback name for future use
+ // Save the callback name for future use
oldCallbacks.push( callbackName );
}
@@ -79,11 +90,11 @@ jQuery.ajaxPrefilter( "json jsonp", function( s, originalSettings, jqXHR ) {
}
responseContainer = overwritten = undefined;
- });
+ } );
// Delegate to script
return "script";
}
-});
+} );
-});
+} );