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

Fixes gh-2323
Closes gh-2464
Ref a2ae215d99
This commit is contained in:
Oleg Gaidarenko
2015-07-10 20:58:43 +03:00
parent 1682d36be2
commit 3d850edb13
2 changed files with 40 additions and 5 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 ] ) {