diff options
author | jaubourg <j@ubourg.net> | 2011-01-13 02:05:39 +0100 |
---|---|---|
committer | jaubourg <j@ubourg.net> | 2011-01-13 02:05:39 +0100 |
commit | 667a3b31e6a27cfe3f209765d583bff584ecc2f6 (patch) | |
tree | 10041ddf131076e1d570234b4fb76f9d3d8f4ba2 /src/ajax/script.js | |
parent | b07d43c649240a78f5e832e2825db3af87357932 (diff) | |
download | jquery-667a3b31e6a27cfe3f209765d583bff584ecc2f6.tar.gz jquery-667a3b31e6a27cfe3f209765d583bff584ecc2f6.zip |
Reworked script and xhr abort logic to take advantage of the fact jXHR.abort will complete the request itself if not done already.
Diffstat (limited to 'src/ajax/script.js')
-rw-r--r-- | src/ajax/script.js | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/src/ajax/script.js b/src/ajax/script.js index 75f34fce2..645ddf335 100644 --- a/src/ajax/script.js +++ b/src/ajax/script.js @@ -47,7 +47,7 @@ jQuery.ajax.transport("script", function(s) { script.src = s.url; // Attach handlers for all browsers - script.onload = script.onreadystatechange = function( _ , statusText) { + script.onload = script.onreadystatechange = function( _ , isAbort ) { if ( ! script.readyState || /loaded|complete/.test( script.readyState ) ) { @@ -59,10 +59,13 @@ jQuery.ajax.transport("script", function(s) { head.removeChild( script ); } + // Dereference the script script = 0; - // Callback - callback( statusText ? 0 : 200, statusText || "success" ); + // Callback if not abort + if ( ! isAbort ) { + callback( 200, "success" ); + } } }; // Use insertBefore instead of appendChild to circumvent an IE6 bug. @@ -70,9 +73,9 @@ jQuery.ajax.transport("script", function(s) { head.insertBefore( script, head.firstChild ); }, - abort: function(statusText) { + abort: function() { if ( script ) { - script.onload( 0 , statusText ); + script.onload(0,1); } } }; |