Hi there,
let me explain my problem.
We need to offer an book to people buying for donation to congress.
( Order form is here: http://christian-heritage.eserbia.org/orde… (funda kabanzi)
Hi there,
let me explain my problem.
We need to offer an book to people buying for donation to congress.
( Order form is here: http://christian-heritage.eserbia.org/order )
So, we have page for selecting persons or institution for donation. Buying goes via PayPal.
After patron pay books using PayPal we must know whom to donate payed books.
We have tried following:
1. Patron should select person in the page ( http://christian-heritage.eserbia.org/order )
2. After this he should click on PayPal button "Pay Now" and this click brings user to PayPal.
... and how to record patron's choice in the form ( http://christian-heritage.eserbia.org/order ) ? After one submit form to PayPal, all data about users selections in the form are lost.
Solution was :
On click on the button "Pay Now", before submit, collect patron's selections (using JS) and using AJAX post data to php script for saving to database. After this, submit only books quantity to PayPal for buying. And this works in all popular browsers except Firefox (tested in Chrome, IE, Opera and all works fine.)
More details with codes (code is simplified):
$('#beforesend').on('click', function(){
var data = 'quantity=' + books_qty;
$('#result li').each(function(ind){
data = data +"&dat[][users choices from form]"
});
....
$.ajax({
url: "app/ordering.php", //Record user choices to database.
type: 'POST',
data: data,
dataType: 'text'
}).done(function(dat) {
console.log(dat);
}).fail(function(jqXHR, textStatus) {
console.log("Firefox paranoia...");
return false;
});
$('#buy').submit(); // Without this line AJAX works... but we can't send post to PayPal.
return true;
}
I can't see security risk if this AJAX post goes to the same domain as script domain.
As I said, this script worked in all tested browsers except Firefox.
Sorry for my not so best English. :(
Best regards.