Ajax: Remove jsonp callbacks through "jQuery#removeProp" method

Fixes gh-2323
Closes gh-2464
This commit is contained in:
Oleg Gaidarenko
2015-07-10 20:58:43 +03:00
parent 3ec73efb26
commit a2ae215d99
2 changed files with 29 additions and 13 deletions

View File

@@ -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 ] ) {