How can I enable or trigger the submit event after ajax post?
For instance I have this form I don’t want to submit it yet,
<form action="https://www.sandbox.paypal.com/cgi-bin/webscr" method="post">
<input type="hidden" name="item_name_1" value="Book 1" />
...
<input type="submit" name="pay" value="Check Out" />
</form>
until this page is called – session_end.php,
unset($_SESSION[SESSION_CART]);
unset($cart);
jquery,
$("input[name=pay]").click(function(){
$("#form-paypal").submit(function(){
$.post('re_post.php', {}, function() {
// I get eternal loop if I use either of these lines below,
//$("#form-paypal").trigger('submit');
//$("#form-paypal").submit();
});
return false;
})
});
I will get the eternal loop on this page re_post.php but the form is not submitted.
You don’t really need the
$("input[name=pay]").clickhandler. A simple.submit()event handler registration should be sufficient.As far as your infinite loop problem is concerned you could append
.data()to the form to track status and avoid the infinite loop: