Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>The problem here is the <code>A</code> in Ajax. You're asynchronously submitting seven forms, but each submission could return at any time, and in any order. What happens if form five takes a minute to return because the server is stalled? </p> <p>Another problem you'll encounter is that browsers typically allow between two and six simultaneous requests, so despite the asynchronous nature of the calls, the browser may stall waiting for a connection.</p> <p>If your application depends on the simultaneous ajax submission of seven forms, one option would be to try to refactor the app so you're making one ajax submission with dynamic parameters selected from all the forms in question. </p> <p>If that's not possible, another approach would be to chain the seven requests, with each request triggered inside the <em>callback</em> of its predecessor. Something like this:</p> <pre><code> ColdFusion.Ajax.submitForm( 'form1', 'multipleforms.cfm', function(){ ColdFusion.Ajax.submitForm( 'form2', 'multipleforms.cfm', function(){ ColdFusion.Ajax.submitForm( 'form3', 'multipleforms.cfm', function(){ // etc }); }); }); </code></pre> <p>Here we have a cascade of submissions, each firing when the previous one is complete. If your redirection can't occur until <code>form7</code> is submitted, that redirection would be inside the callback of the final submission:</p> <pre><code> // forms 1 through 6, then inside the callback of form6: ColdFusion.Ajax.submitForm( 'form7', 'multipleforms.cfm', function(){ location.replace('http://localhost/multipleforms.cfm'); // fires last }); </code></pre> <p>With any approach that could stall the browser, the very first thing you should do is pop up a spinner or progress message so the user understands the app is working. With the chained approach, you could even update a progress bar as each stage is completed.</p> <p>A final more brute-force option would be to make the calls <em>synchronous</em>. <a href="http://help.adobe.com/en_US/ColdFusion/9.0/CFMLRef/WS0ef8c004658c1089-6262c847120f1a3b244-7ffe.html" rel="nofollow">Check out the <code>asynch</code> argument</a>. Of course this <em>will</em> lead to a stall before the redirect, so refactoring is probably the best option from the user experience perspective.</p>
 

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