Note that there are some explanatory texts on larger screens.

plurals
  1. POajax submit multiple forms via jquery
    text
    copied!<p>so suppose I have 3 forms </p> <pre><code>&lt;form name="form1"&gt; &lt;input name="input"&gt;&lt;/input&gt; &lt;submit&gt;&lt;/submit&gt; &lt;/form&gt; &lt;form name="form2"&gt; &lt;input name="input"&gt;&lt;/input&gt; &lt;submit&gt;&lt;/submit&gt; &lt;/form&gt; &lt;form name="form3"&gt; &lt;input name="input"&gt;&lt;/input&gt; &lt;submit&gt;&lt;/submit&gt; &lt;/form&gt; </code></pre> <p>Each of the form has its own submit button</p> <p>now suppose I have another form</p> <pre><code>&lt;form id="submitAll"&gt; &lt;submit value="submit all"&gt;&lt;/submit&gt; &lt;/form&gt; </code></pre> <p>whose sole function is to submit all the other 3 forms simultaneously....now here are the constraints:</p> <ol> <li>when submitAll is submitted, it has to do so using Ajax and forward the input data from all the other 3 forms to processor.php preferably via POST</li> <li>processor.php needs to be able to distinguish between which inputs go to which form...and then process the inputs of each form separately</li> </ol> <p>My question is....what is be the best way to make processor.php be able to distinguish which inputs belong to which form.....</p> <p>My previous attempts was to use jquery's serialize to serialize all the 3 forms' inputs, but then it would merge all the inputs into one string and notice that since the inputs in the forms have the same name, the string goes like "input=blah&amp;input=blah&amp;input=blah" and I can't distinguish between which input goes to which form.....</p> <p>It is highly preferable to have the inputs in the forms to have the same name so that processor.php can execute smoothly</p> <p>Is there away to make POST strings be passed as arrays or json or any other format so that processor.php can distinguish which input goes to which form without making the input names differ? remember it needs to do so via Ajax</p> <p>thanks in advance!!!</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