Side navigation
Ticket #5048: jquery-jsonp-404-memleak-fix.patch
File jquery-jsonp-404-memleak-fix.patch, 1.6 KB (added by sigmunau, August 14, 2009 03:36PM UTC)
attempted fix for timeout and 404 (etc) errors with jsonp requests
Index: include/platform/jquery/jquery-1.3.2.js
===================================================================
--- include/platform/jquery/jquery-1.3.2.js (revision 5380)
+++ include/platform/jquery/jquery-1.3.2.js (working copy)
@@ -3425,6 +3425,14 @@
s.data = (s.data + "").replace(jsre, "=" + jsonp + "$1");
s.url = s.url.replace(jsre, "=" + jsonp + "$1");
+ if ( s.timeout > 0 ) {
+ var timed_out = s.timed_out = false;
+ var jsonp_timer = s.jsonp_timer = setTimeout(function() {
+ dump('Whee! magic timeout function called!');
+ timed_out = true;
+ jQuery.handleError(s, s.xhr, "error");
+ },s.timeout );
+ }
// We need to make sure
// that a JSONP style response is executed properly
s.dataType = "script";
@@ -3432,6 +3440,8 @@
// Handle JSONP-style loading
window[ jsonp ] = function(tmp){
+ if(!timed_out) {
+ clearTimeout(jsonp_timer);
data = tmp;
success();
complete();
@@ -3440,6 +3450,7 @@
try{ delete window[ jsonp ]; } catch(e){}
if ( head )
head.removeChild( script );
+ }
};
}
@@ -3682,7 +3693,8 @@
if ( s.global )
jQuery.event.trigger( "ajaxError", [xhr, s, e] );
if( s.dataType == 'script') {
- window[ s._jsonp ] = undefined;
+ clearTimeout(s.jsonp_timer);
+ window[ s._jsonp ] = undefined;
try{ delete window[ s._jsonp ]; } catch(e){}
if ( s._script ) {
var head = document.getElementsByTagName("head")[0];
Download in other formats:
Original Format
File jquery-jsonp-404-memleak-fix.patch, 1.6 KB (added by sigmunau, August 14, 2009 03:36PM UTC)
attempted fix for timeout and 404 (etc) errors with jsonp requests
Index: include/platform/jquery/jquery-1.3.2.js
===================================================================
--- include/platform/jquery/jquery-1.3.2.js (revision 5380)
+++ include/platform/jquery/jquery-1.3.2.js (working copy)
@@ -3425,6 +3425,14 @@
s.data = (s.data + "").replace(jsre, "=" + jsonp + "$1");
s.url = s.url.replace(jsre, "=" + jsonp + "$1");
+ if ( s.timeout > 0 ) {
+ var timed_out = s.timed_out = false;
+ var jsonp_timer = s.jsonp_timer = setTimeout(function() {
+ dump('Whee! magic timeout function called!');
+ timed_out = true;
+ jQuery.handleError(s, s.xhr, "error");
+ },s.timeout );
+ }
// We need to make sure
// that a JSONP style response is executed properly
s.dataType = "script";
@@ -3432,6 +3440,8 @@
// Handle JSONP-style loading
window[ jsonp ] = function(tmp){
+ if(!timed_out) {
+ clearTimeout(jsonp_timer);
data = tmp;
success();
complete();
@@ -3440,6 +3450,7 @@
try{ delete window[ jsonp ]; } catch(e){}
if ( head )
head.removeChild( script );
+ }
};
}
@@ -3682,7 +3693,8 @@
if ( s.global )
jQuery.event.trigger( "ajaxError", [xhr, s, e] );
if( s.dataType == 'script') {
- window[ s._jsonp ] = undefined;
+ clearTimeout(s.jsonp_timer);
+ window[ s._jsonp ] = undefined;
try{ delete window[ s._jsonp ]; } catch(e){}
if ( s._script ) {
var head = document.getElementsByTagName("head")[0];