0

I am using the Charge plugin to handle my Stripe payments. How could I submit this form via Ajax Post and get the response? I have tried using the following code but it tells me it's a bad request:

this.ajaxReq = $.ajax({
   url: 'charge/charge',
   data: $('#charge-form').serialize()
}) .done(function(data) {
   console.log('success!');
   console.log(data);
}) .fail(function(data){
   console.log(data);
});
4
  • Are you using the Stripe.js checkout option, as detailed in the Charge documentation? Apr 29, 2017 at 18:34
  • Yes, I'm looking to modify the $form.get(0).submit(); that's part of jquery.charge so that this submission is sent via Ajax without a page refresh
    – Jai Sandhu
    Apr 29, 2017 at 23:27
  • 1
    Have you specified the $.ajax method? It uses GET by default, but you need to submit the form using POST. Apr 30, 2017 at 4:11
  • You're welcome. I added my comment as an answer. If you can accept it, then we can close this one out. Apr 30, 2017 at 23:15

1 Answer 1

1

You need to specify the HTTP method used by the $.ajax method.

By default, it uses GET, but you need to submit the form using POST.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.