diff options
author | Oleg Gaidarenko <markelog@gmail.com> | 2015-08-16 09:59:58 +0300 |
---|---|---|
committer | Oleg Gaidarenko <markelog@gmail.com> | 2015-09-07 20:03:50 +0300 |
commit | 10fdad742a2a6aa9f0e00b3e04fc5264797c53c7 (patch) | |
tree | 6b6d7b1375ff88f4bebbfa0703f7b595eb485df9 /src/ajax/jsonp.js | |
parent | 7aa46e0df8a673e6b00550bbbbed21eed50108b7 (diff) | |
download | jquery-10fdad742a2a6aa9f0e00b3e04fc5264797c53c7.tar.gz jquery-10fdad742a2a6aa9f0e00b3e04fc5264797c53c7.zip |
Build: Update jscs and lint files
Fixes gh-2056
Diffstat (limited to 'src/ajax/jsonp.js')
-rw-r--r-- | src/ajax/jsonp.js | 26 |
1 files changed, 14 insertions, 12 deletions
diff --git a/src/ajax/jsonp.js b/src/ajax/jsonp.js index f469344e0..666e5d1e6 100644 --- a/src/ajax/jsonp.js +++ b/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 ) { @@ -26,7 +26,7 @@ jQuery.ajaxPrefilter( "json jsonp", function( s, originalSettings, jqXHR ) { "url" : typeof s.data === "string" && ( s.contentType || "" ) - .indexOf("application/x-www-form-urlencoded") === 0 && + .indexOf( "application/x-www-form-urlencoded" ) === 0 && rjsonp.test( s.data ) && "data" ); @@ -46,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 @@ -63,7 +63,8 @@ jQuery.ajaxPrefilter( "json jsonp", function( s, originalSettings, jqXHR ) { }; // Clean-up function (fires after converters) - jqXHR.always(function() { + jqXHR.always( function() { + // If previous value didn't exist - remove it if ( overwritten === undefined ) { jQuery( window ).removeProp( callbackName ); @@ -75,10 +76,11 @@ jQuery.ajaxPrefilter( "json jsonp", function( s, originalSettings, jqXHR ) { // 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 ); } @@ -88,11 +90,11 @@ jQuery.ajaxPrefilter( "json jsonp", function( s, originalSettings, jqXHR ) { } responseContainer = overwritten = undefined; - }); + } ); // Delegate to script return "script"; } -}); +} ); -}); +} ); |