Reputation: 1421
<form id="form1">...</form>
<form id="form2">...</form>
I want to submit form1
to host1
first for validation,if the response is true
then submit form2
to host2
,both should be using POST
.
How to do this with jQuery?
Upvotes: 1
Views: 1001
Reputation: 13497
Here's an implementation using AJAX
$("#form1").submit(function(){
$.post( $(this).attr("action"), $(this).serialize(),
function(){
$.post( $("#form2").attr("action"), $("#form2").seriallize(),
function(){
alert("Now what?");
});
});
});
Here instead of checking for the response to be 'true' I just assume that it will only have a successful response if the validation passes as 'true'
Upvotes: 1