POST'ing to Multiple Forms with JQuery

Discussion in 'jQuery' started by kuepper, Feb 16, 2010.

  1. #1
    I'm trying to POST the same form to multiple locations using JQuery.

    My code so far is this:

    
    	$('#submitbutton').click(function(){
    		$.post('form1.php', $('#myform').serialize(), function(data, textStatus) {});
    		$.post('form2.php',$('#myform').serialize(), function(data, textStatus){});
    		window.location.href = 'continue.php';
    	});
    
    Code (markup):
    However, when I click the submit button the first time, it does nothing and resets the form fields. When I fill them out and submit again, then it submits to the forms and redirects.

    Any ideas as to why it takes two times to do this?

    Thanks in advance for any help!
     
    kuepper, Feb 16, 2010 IP