jQuery onunload do action if button was pressed
<p>I have a small website who's client side framework is <em>jQuery</em>.</p>

<p>I have a page where I need to do some <em>AJAX</em> action before the page unloads but that action may not fire if a certain button was clicked.</p>

<p>I was trying this with:</p>

<pre><code>&lt;body onbeforeunload="myaction();"&gt; 
</code></pre>

<p>But how do I know that certain button was clicked or not?</p>
