Using JQuery to POST to Multiple Files
I am trying to make a script that allows one form to POST to multiple PHP files.
Here's what I have right now:
$('#submitbutton').click(function(){
$.post('form1.php', $('#myform').serialize(), function(data, textStatus) {});
$.post('form2.php',$('#myform').serialize(), function(data, textStatus){});
window.location.href = 'thank-you.php';
});
When I click the submit button the first time, nothing happens and my data entered disappears. When I click a second time, it goes through and submits the information to form2.php and redirects. Any ideas how to make this all happen with the first click?