diff --git a/src/ajax/jsonp.js b/src/ajax/jsonp.js index 6b0f95d..05229c7 100644 --- a/src/ajax/jsonp.js +++ b/src/ajax/jsonp.js @@ -52,8 +52,21 @@ jQuery.ajaxPrefilter( "json jsonp", function( s, originalSettings, jqXHR ) { // Clean-up function jqXHR.always(function() { - // Set callback back to previous value - window[ jsonpCallback ] = previous; + // HACK workaround for bug #8744 + // if the jsonp request timed out, we need to keep the callback + // function alive, as it may be fired by some browser (IE9, FF) + // at a later time. However, since we encountered already the + // timeout, we replace it by an empty dummy function. + // This is VERY UGLY so beware! + if ( responseContainer === undefined ) { + window[ jsonpCallback ] = function () { + return; + }; + } + else { + // Set callback back to previous value + window[ jsonpCallback ] = previous; + } // Call if it was a function and we have a response if ( responseContainer && jQuery.isFunction( previous ) ) { window[ jsonpCallback ]( responseContainer[ 0 ] );