Vote count:
0
I need to save some data to the database through AJAX when a form is submitted, and then resume the default action of the form and submit it to PayPal. When done this way, the data is successfully saved in the database, but the form does not submit further.
$('#saveBeforePay').on('submit', function(e){
e.preventDefault();
$.post('ajax/save-cart', $(this).serialize())
.done(function(response){
if ( response == 200 ) {
return true;
}
});
});
Another way I tried is this
$('#saveBeforePay').on('submit', function(e){
$.post('ajax/save-cart', $(this).serialize())
.done(function(response){
if ( response != 200 ) {
e.preventDefault();
}
});
});
Now the form submits but the data does not save to the database. I get this info from the network tab
Request Headers CAUTION: Provisional headers are shown And the Status Text
is Canceled
What is wrong here ?
asked 1 min ago
Aucun commentaire:
Enregistrer un commentaire