我有一个 PayPal 按钮,它将表单提交到表单action=""
属性中指定的 url。我希望此按钮执行的操作是在提交表单的同时(或大致相同)触发 ajax 调用。
所以表格看起来像这样:
<?php echo('
<form action="https://www.sandbox.paypal.com/cgi-bin/webscr" method="post" id="payWithPayPalForm">
<input type="hidden" name="cmd" value="_xclick">
<input type="hidden" name="business" value="me@mydomain.com">
<input type="hidden" name="amount" value="'.$price.'">
<input type="hidden" name="bn" value="PP-BuyNowBF:btn_buynowCC_LG.gif:NonHostedGuest" >
<input type="image" src="https://www.paypalobjects.com/en_US/i/btn/btn_paynowCC_LG.gif" border="0" id="payWithPayPalButton" name="submit" alt="PayPal - The safer, easier way to pay online!">
<img alt="" border="0" src="https://www.paypalobjects.com/pl_PL/i/scr/pixel.gif" width="1" height="1">
</form>
');
?>
ajax请求如下:
$.ajax({
type: "POST",
url: "classes/acceptOfferFunction.php",
data: {
hash: getURLParameter('hash'),
hash2: getURLParameter('hash2')
},
success: function (result) {
}
});