diff options
author | Oleg Gaidarenko <markelog@gmail.com> | 2015-07-10 20:58:43 +0300 |
---|---|---|
committer | Oleg Gaidarenko <markelog@gmail.com> | 2015-07-13 01:34:09 +0300 |
commit | a2ae215d999637e8d9d0906abcbf6b1ca35c8e6e (patch) | |
tree | f4cdf3356d8aefe10f83f320f222e14d5a684933 /src/ajax | |
parent | 3ec73efb26317239a4f22f0b023b0b99a4300a20 (diff) | |
download | jquery-a2ae215d999637e8d9d0906abcbf6b1ca35c8e6e.tar.gz jquery-a2ae215d999637e8d9d0906abcbf6b1ca35c8e6e.zip |
Ajax: Remove jsonp callbacks through "jQuery#removeProp" method
Fixes gh-2323
Closes gh-2464
Diffstat (limited to 'src/ajax')
-rw-r--r-- | src/ajax/jsonp.js | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/src/ajax/jsonp.js b/src/ajax/jsonp.js index a04898f67..f469344e0 100644 --- a/src/ajax/jsonp.js +++ b/src/ajax/jsonp.js @@ -64,8 +64,14 @@ jQuery.ajaxPrefilter( "json jsonp", function( s, originalSettings, jqXHR ) { // Clean-up function (fires after converters) jqXHR.always(function() { - // Restore preexisting value - window[ callbackName ] = overwritten; + // 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 ] ) { |