You can use the
jQuery Forms Plugin:
Code:
$(document).ready(function() {
$('#form1, #form2, #form3').ajaxForm(function() {
// optionally do stuff here after forms submitted
});
$('#myButton').click(function() {
$('#form1, #form2, #form3').ajaxSubmit();
return false;
});
});
NB: to use the "#" ID selectors, you'll need to give each of your forms an ID attribute.
If you didn't want to name each form in the JS code, and simply apply it to every form on the page, you could use each() to apply the same:
Code:
$(document).ready(function() {
$('form').each(function(){
$(this).ajaxForm(function() {
// optionally do stuff here after forms submitted
});
});
$('#myButton').click(function() {
$('form').each(function(){
$(this).ajaxSubmit();
});
return false;
});
});