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:
- User tries to navigate away from page.
- Show a dialogue confirming they wish to leave the page and lose their query progress. (Use
beforeunload
) - 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?)
Is this possible?