I have multiple forms on the same page but I want to submit all forms together once instead of submitting one at a time. My approach is to clone all the data inside a another form and submit at once but its kind of overhead . So, is there a another approach to submit multiple form data once.
Thanks in advance for any help.
This will submit all form elements via ajax when 'button'
is clicked
$('button').click(function() {
$('form').each(function() {
$.post(this.action, $form.serialize());
});
});
Note that this will not refresh the page, as they are all submitted via ajax...
Hmmmm. This might sound drastic, but why not encapsulate all the INPUT
s into just one FORM
element? If not that, I think you'll have to rely on AJAX to do this for you.
You could either do it the way that your doing it, or you can submit the forms via ajax requests. If there is no need for it to be asynchronous, I would probably do it the way you plan on doing it.