title: Is an AJAX request killed when a link gets clicked?
body: <p>I have a website with an AJAX cart. The concept is pretty simple: you end up on a page with a product and can click the <code>Buy Now</code> button. When you do so, the JavaScript code adds the product to the cart, changes the cart visual with the new count, and sends an AJAX request to the server to report the change.</p>
  <p>What I'm wondering about, since the client and the server may take a while to process the AJAX request, is... will the client clicking a link to move to another page (i.e. &quot;next product&quot;) before the AJAX is reported as successful stop the AJAX request at all?</p>
  <pre><code>// prepare request...
  ...snip...
  // send request (usually a POST)
  jQuery.ajax(uri, ajax_options);
  // return to user
  
  // will a click on a link cancel the AJAX call after this point?
  </code></pre>
  <p>Further, I have timed AJAX requests. If the user clicks on a link before those timed requests happen, they will be lost for sure. Assuming that the click does not cancel an AJAX request, would starting one in the <code>unload</code> event work? Would using a cookie be better/safer than attempting another AJAX request? (although if the user clicks an external link, the <code>unload</code> is really the only solution I can think of to save that data...)</p>
  <p>As a side note: I do not want to darken the screen when the user adds an item to the cart so that way the user can continue to do things... but if the AJAX needs to be confirmed before a link can be clicked, I'd have to make sure clicks cannot be used until then.</p>
  <hr />
  <p><strong>Update:</strong></p>
  <p>I thinks that some of you are missing the point. I do not care about the <code>done()</code> or <code>completed()</code> functions getting called on the client side. What I do care about is making sure that in the end I get all the data on the server.</p>
  <p>I understand that's asynchronous, but what I want to make sure of is avoiding loss of data, especially if the link goes to another website (to the same website, I am really thinking to make use of a cookie to make sure that the data of delayed AJAX requests get to the server no matter what.)</p>
  <p>Also, the idea of timed data requests is to avoid heavy loads on the server. With a properly timed set of AJAX requests, the client and server both work a lot better!</p>