I am having trouble using jquery to submit a form. It was working before
Posted
by noah
on Stack Overflow
See other posts from Stack Overflow
or by noah
Published on 2010-05-09T05:22:43Z
Indexed on
2010/05/09
5:28 UTC
Read the original article
Hit count: 192
When a user clicks a link it uses jquery ajax to submit a form to go to paypal. Not working for some reason. Really appreciate any help...
LINK TO CLICK
I put this in an href for onClick:
javascript:go_paypal();
CODE TO EXECUTE ON CLICK
function go_paypal() {
data = 'req_paypal=1';
$.blockUI({ message: '<h1> Going to Paypal...</h1>',css:{background:'#000'} });
$.ajax({
type: "POST",
url: "index.php",
data: data,
success: function(data) { $("#paypal_form").html(data); $("#payPalForm").submit(); } ,
error: function() {$.unblockUI(); alert('Unable to communicate to server.'); }
});
return false;
}
CODE TO GO ON SUBMIT
if(isset($_POST['req_paypal']) && $_POST['req_paypal'] == 1 ) {
$sql = 'INSERT INTO `transactions` (id,type,ip,time,ammount,status) VALUES (NULL,1,\''.$_SERVER['REMOTE_ADDR'].'\',\''.time().'\',\''.$global['paypal_prod_amount'].'\',0) ';
echo $sql;
mysql_query($sql);
$id = mysql_insert_id();
$html = '
<form action="https://www.sandbox.paypal.com/cgi-bin/webscr" method="post" id="payPalForm">
<input type="hidden" name="item_number" value="One Year of Imgur Pro">
<input type="hidden" name="cmd" value="_xclick">
<input type="hidden" name="no_note" value="1">
<input type="hidden" name="business" value="'.$global['paypal_email'].'">
<input type="hidden" name="custom" value="'.base64_encode($id).'">
<input type="hidden" name="currency_code" value="USD">
<input type="hidden" name="return" value="'.$global['paypal_return'].'">
<input name="item_name" type="hidden" id="item_name" value="One Year of Imgur Pro" >
<input name="amount" type="hidden" id="amount" value="'.$global['paypal_prod_amount'].'" >
</form>
';
echo $html;exit;
}
© Stack Overflow or respective owner