jQuery, do something while form is posting or in action
<p>I got the following form:</p>

<pre><code>&lt;form name="x" method="post" action="/message.jsp" onsubmit="validate(this)"&gt;

&lt;input type="button" name="Export" value="Export" onclick="this.form.action='ReportExecute.jsp';this.form.submit();"&gt;

&lt;/form&gt;
</code></pre>

<p>What I want to do is, I am trying to do something (like displaying an spinner or disabling button) when the export button is cliecked (this button create a csv file to be downloaded eventually after loading some specific data which is specified in the form fields) until the form action (which is exporting data) or form post is finished.</p>

<p>What I did was something like this:</p>

<pre><code>$(document).ready(function(){
    $('form[name="x"]').submit(function() {
        alert("test");
    });
});
</code></pre>

<p>I expected to get the alert when I click the export button since the form does some actions by clicking this button, But it never worked! as if the form does not post anything at all!</p>

<p>Would be grateful for some help . thanks</p>
