Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to know when all ajax calls are complete
    primarykey
    data
    text
    <p>I have a table style page with rows. Each row has a checkbox. I can select all/many checkboxes and click "submit" and what is does is a Jquery ajax call for each row. </p> <p>Basically I have a form for each row and I iterate over all the checked rows and submit that form which does the jquery ajax call.</p> <p>So I have a button that does:</p> <pre><code> $("input:checked").parent("form").submit(); </code></pre> <p>Then each row has:</p> <pre><code> &lt;form name="MyForm&lt;%=i%&gt;" action="javascript:processRow(&lt;%=i%&gt;)" method="post" style="margin:0px;"&gt; &lt;input type="checkbox" name="X" value="XChecked"/&gt; &lt;input type="hidden" id="XNumber&lt;%=i%&gt;" name="X&lt;%=i%&gt;" value="&lt;%=XNumber%&gt;"/&gt; &lt;input type="hidden" id="XId&lt;%=i%&gt;" name="XId&lt;%=i%&gt;" value="&lt;%=XNumber%&gt;"/&gt; &lt;input type="hidden" id="XAmt&lt;%=i%&gt;" name="XAmt&lt;%=i%&gt;" value="&lt;%=XAmount%&gt;"/&gt; &lt;input type="hidden" name="X" value="rXChecked"/&gt; &lt;/form&gt; </code></pre> <p>This form submits to processRow:</p> <pre><code> function processRow(rowNum) { var Amount = $('#XAmt'+rowNum).val(); var XId = $('#XId'+rowNum).val(); var XNum = $('#OrderNumber'+rowNum).val(); var queryString = "xAmt=" + "1.00" + "&amp;xNumber=" + OrdNum + "&amp;xId=" + xId; $('#coda_'+rowNum).removeClass("loader"); $('#coda_'+rowNum).addClass("loading"); $.ajax({ url: "x.asp", cache: false, type: "POST", data: queryString, success: function(html){ $('#result_'+rowNum).empty().append(html); $('#coda_'+rowNum).removeClass("loading"); $('#coda_'+rowNum).addClass("loader"); } }); } </code></pre> <p>What I wanted to know is, from this is there a way I can tell if all my Ajax calls are complete. Reason being that want to enable/disable the submit button while all these calls are taking place.</p> <p>Thanks and please note that I had to mangle my variable names due to the sensitivity of the application, so many of them may be duplicated.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload