@@ -380,29 +380,21 @@ jQuery.extend({
380
380
}
381
381
382
382
// Wait for a response to come back
383
- var onreadystatechange = function ( isTimeout ) {
383
+ var onreadystatechange = xhr . onreadystatechange = function ( isTimeout ) {
384
384
// The request was aborted, clear the interval and decrement jQuery.active
385
385
if ( ! xhr || xhr . readyState === 0 ) {
386
- if ( ival ) {
387
- // clear poll interval
388
- clearInterval ( ival ) ;
389
- ival = null ;
390
-
391
- // Handle the global AJAX counter
392
- if ( s . global && ! -- jQuery . active ) {
393
- jQuery . event . trigger ( "ajaxStop" ) ;
394
- }
386
+ requestDone = true ;
387
+ xhr . onreadystatechange = jQuery . noop ;
388
+
389
+ // Handle the global AJAX counter
390
+ if ( s . global && ! -- jQuery . active ) {
391
+ jQuery . event . trigger ( "ajaxStop" ) ;
395
392
}
396
393
397
394
// The transfer is complete and the data is available, or the request timed out
398
395
} else if ( ! requestDone && xhr && ( xhr . readyState === 4 || isTimeout === "timeout" ) ) {
399
396
requestDone = true ;
400
-
401
- // clear poll interval
402
- if ( ival ) {
403
- clearInterval ( ival ) ;
404
- ival = null ;
405
- }
397
+ xhr . onreadystatechange = jQuery . noop ;
406
398
407
399
status = isTimeout === "timeout" ?
408
400
"timeout" :
@@ -446,19 +438,14 @@ jQuery.extend({
446
438
}
447
439
} ;
448
440
449
- if ( s . async ) {
450
- // don't attach the handler to the request, just poll it instead
451
- var ival = setInterval ( onreadystatechange , 13 ) ;
452
-
453
- // Timeout checker
454
- if ( s . timeout > 0 ) {
455
- setTimeout ( function ( ) {
456
- // Check to see if the request is still happening
457
- if ( xhr && ! requestDone ) {
458
- onreadystatechange ( "timeout" ) ;
459
- }
460
- } , s . timeout ) ;
461
- }
441
+ // Timeout checker
442
+ if ( s . async && s . timeout > 0 ) {
443
+ setTimeout ( function ( ) {
444
+ // Check to see if the request is still happening
445
+ if ( xhr && ! requestDone ) {
446
+ onreadystatechange ( "timeout" ) ;
447
+ }
448
+ } , s . timeout ) ;
462
449
}
463
450
464
451
// Send the data
0 commit comments