I have spent the day studying up on jquery because I think it will allow me to do this. I have a paypal form and I want the “onClick” button to send this field to my sql table
<input type="hidden" name="amount" id="amount" value="0.05">
Meanwhile my PayPal button is doing this:
<input class="btn btn-primary" onClick="send()" type="submit" value="Subscribe">
How can I pass this value to my process_plan.php? So far I have this but it’s hanging and not working.
function send() {
var id = $('#amount').val();
var result;
$.ajax({
type: "POST",
url: "process_plan.php",
data: {
"amount" : amount
},
async: true,
dataType: "html",
success: function(response) {
result = response;
},
error: function(response) {
alert("Oh no! An error occured!");
}
});
return result;
}
I apologize if the code is really wonky – really my first day studying up on Jquery and Ajax.
Don’t know if that is the problem, but I think you have a little mistake in your code.
Please try :
...data: {
amount : "amount"
},
...
In case that amount is a var too, delete the “