Bug Tracker

Ticket #2935: ajax-abort.diff

File ajax-abort.diff, 1.4 kB (added by joern, 7 months ago)
  • src/ajax.js

     
    303303                s.accepts._default ); 
    304304        } catch(e){} 
    305305 
    306         // Allow custom headers/mimetypes 
     306        // Allow custom headers/mimetypes and early abort 
    307307        if ( s.beforeSend && s.beforeSend(xhr, s) === false ) { 
    308             // cleanup active request counter 
    309             s.global && jQuery.active--; 
     308            // Handle the global AJAX counter 
     309            if ( s.global && ! --jQuery.active ) 
     310                jQuery.event.trigger( "ajaxStop" ); 
    310311            // close opended socket 
    311312            xhr.abort(); 
    312313            return false; 
     
    317318 
    318319        // Wait for a response to come back 
    319320        var onreadystatechange = function(isTimeout){ 
     321            // The request was aborted, clear the interval and decrement jQuery.active 
     322            if (xhr.readyState == 0) { 
     323                if (ival) { 
     324                    // clear poll interval 
     325                    clearInterval(ival); 
     326                    ival = null; 
     327                    // Handle the global AJAX counter 
     328                    if ( s.global && ! --jQuery.active ) 
     329                        jQuery.event.trigger( "ajaxStop" ); 
     330                } 
    320331            // The transfer is complete and the data is available, or the request timed out 
    321             if ( !requestDone && xhr && (xhr.readyState == 4 || isTimeout == "timeout") ) { 
     332            } else if ( !requestDone && xhr && (xhr.readyState == 4 || isTimeout == "timeout") ) { 
    322333                requestDone = true; 
    323334 
    324335                // clear poll interval