ajaxForm asynchronous call
<p>I have a situation where I needed to get data from a form submit(). I have given the url in the action and the values to be sent as input elements. The submit is to a REST web service. </p>

<p>I want to retrieve the values from that submit which cannot be done in normal form.submit(), hence I had to use the ajaxForm() call. I think The handler mentioned for success option is called after successful completion of the REST method. I have also given the async:false option as I want to complete the call and then only proceed.</p>

<p>My problem is that The handler is executed after other code i.e. after the call is made the code after the ajax call is executed and then the handler. This is not right if i give async:false right??</p>

<p>This is my code for your reference:</p>

<pre><code> &lt;form id="form4" action="http://comp1:8080/RestWSGS/jersey/ExcelHtmlTablePlain" style="display:none"
         enctype="multipart/form-data" method="post"&gt;
         &lt;input id ="username" name="username" type="hidden" /&gt;
         &lt;input id ="wbk" name="wbk" type="hidden" value="new"  /&gt; 
        &lt;input type="submit"  style="display:none" /&gt;
&lt;/form&gt;

$(function () {
    $('#form4').submit();
    alert(tbLHSString);
}

function showResponse(responseText, statusText, xhr, $form) {

    if (xhr.readyState == 4) {
        tbLHSString = responseText;
    }
    alert('status: ' + statusText + '\n\nresponseText: \n' + responseText + '\n\nThe output div should have already been updated with the responseText.');
    executed == true;
}
</code></pre>

<p>On the server console I can see that the REST executes perfectly. But I get the variable as undefined and only then the alert from the showResponse happens.</p>

<p>Please help me make this call synchronous!!!
Kavita</p>
