0

I have already read a lot of topics but no result. I want to submit two forms with 1 button to php script.

$(document).ready(function() {
    $("#subbut").click(function() {
        $.post($("#firstform").attr("action"), $("#firstform").serialize()+$("#secondform").serialize(),
              function() {
                alert('Both forms submitted');
              });
      });
  });

I tried this but it submit only 1 form. Where is the problem?

user2417332
  • 49
  • 1
  • 2
  • 9
  • 1
    Is #subbut the 'submit' button of the form? If yes, you have to prevent default action. What is happening is that after you click the page the browser effectively ignores the callback and post the first form data to the action – Agi Sferro May 24 '13 at 11:56

1 Answers1

0

You can try with trigger,Just trigger the submit event of the second form. and then serialize the data of both form and post that data where you want.

$(document).ready(function() {
    $("#subbut").click(function() {
                   $('#form2').trigger('sumbit');          
              function() {

              });
      });
  });
Pramod Kumar Sharma
  • 7,851
  • 5
  • 28
  • 53