Reputation: 6778
I am having problems of submitting a post using jquery , Below is the code snippet:
Jquery
$("#pay").click(function () {
if ($("#terms").attr("checked")) {
$("#frmWorldPay").submit();
return true;
} else {
alert("Please agree to the terms and conditions.");
return false;
}
});
View
<form method="post" action="https://secure.wp3.rbsworldpay.com/wcc/purchase" id="frmWorldPay">
<input type="hidden" name="instId" value="261901" />
<input type="hidden" name="cartId" value="<%: Model.GUID %>" />
<input type="hidden" name="currency" value="GBP" /></form>
<div id="worldPayBtnWrap">
<p> <%: Html.CheckBox("terms") %> by ticking this box you are agreeing to our <%: Html.ActionLink("terms & conditions", "Terms", "About")%></p>
<input type="image" src="/content/images/btnWorldPay.png" alt="Pay via World Pay" id="pay" />
</div>
Upvotes: 0
Views: 147
Reputation: 98423
Try returning false, not true. True causes it to go ahead and submit the form that the image is in (even though you just triggered a submit on a different form) or, apparently, if the image isn't in a form, causes it to reload the page.
Upvotes: 1