title: Send an AJAX event on beforeunload confirmation
body: <p>I have a page where a person can query a large database (often can take half a minute or more). I want to do the following:</p>
  
  <ol>
  <li>User tries to navigate away from page.</li>
  <li>Show a dialogue confirming they wish to leave the page and lose their query progress. (Use <code>beforeunload</code>)</li>
  <li>If the user clicks "confirm", then I want to kill the query (via AJAX) before allowing them to navigate away. (use unload, but how can I get the page to not exit before ajax completes?)</li>
  </ol>
  
  <p>Is this possible? </p>