0
votes

Is there any way to submit multiple forms using ajax ?

for eg form id="form1" and form id="form2"

both the forms will be submitted separately as needed.

to be more specific i am using this for my form submission.

thanks

1

1 Answers

3
votes

Sure:

$('#form1, #form2').submit();

after having AJAXified them of course:

$(function() {
    $('#form1, #form2').submit(function() {
        $.ajax({
            url: this.action,
            type: this.method,
            data: $(this).serialize(),
            success: function(result) {
                alert('thanks for submitting');
            }
        });
        return false;
    });
});

UPDATE:

After your update it seem that you are using the jquery form plugin. In this case you could force the AJAX submission by invoking the ajaxSubmit method on the 2 forms like this:

$('#form1, #form2').ajaxSubmit();