title: How to abort list of all the pending ajax requests using jquery?
body: <p>This is my function</p>
  
  <pre><code>  var xhr;
      function abortAjax() {
          $.each(xhrPool, function(idx, jqXHR) {
              jqXHR.abort();
          });
      }
      $(document).ready(function() {
          fn = function() {
              xhrPool = [];
              xhr = $.ajax({
                  url: '/getUrl',
                  beforeSend: function(jqXHR) {
                      xhrPool.push(jqXHR);
                  },
                  complete: function(jqXHR, data) {
                      if (jqXHR.statusText != "error") {
                          //my functions
                      }
                  }
              });
          };
  
          var interval = setInterval(fn, 5000);
      });
  
      function abort_allAjax(){     
        //I need to make fresh ajax call when it enters this function      
          function abortAjax();
          fn();
      }
  </code></pre>
  
  <p>fn is my function for updating table data. It is updated every 5 seconds.So many pending ajax requests will be there.</p>
  
  <p>When i call abort_allAjax() function, new data needs to be updated, so i need to abort all the pending requests and make a fresh ajax call.</p>
  
  <p>I tried to use</p>
  
  <pre><code> function abortAjax() {
          $.each(xhrPool, function(idx, jqXHR) {
              jqXHR.abort();
          });
      }
  </code></pre>
  
  <p>But it is aborting only the last ajax call. If anyone has idea or any working examples to abort all the ajax calls, please help me!! Thanks a lot in advance!!</p>