<p>You need to specify the HTTP method used by <a href="http://api.jquery.com/jquery.ajax/" rel="nofollow noreferrer">the <code>$.ajax</code> method</a>. </p>

<p>By default, it uses <code>GET</code>, but you need to submit the form using <code>POST</code>.</p>

CC BY-SA 3.0
2017-04-30T22:36:08.660Z
2017-04-30T22:36:08.660Z
Stephen Lewis
<p>I am using the <a href="https://squarebit.co.uk/software/craft/charge" rel="nofollow noreferrer">Charge</a> 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:</p>

<pre><code>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);
});
</code></pre>

CC BY-SA 3.0
2017-04-29T18:34:18.593Z
Are you using the Stripe.js checkout option, as detailed in [the Charge documentation](https://squarebit.co.uk/software/craft/charge/usage/quickstart/using-stripe-js)?
Stephen Lewis
CC BY-SA 3.0
2017-04-29T23:27:05.793Z
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
CC BY-SA 3.0
2017-04-30T04:11:07.567Z
Have you specified the `$.ajax` method? It uses `GET` by default, but you need to submit the form using `POST`.
Stephen Lewis
CC BY-SA 3.0
2017-04-30T23:15:12.043Z
You're welcome. I added my comment as an answer. If you can accept it, then we can close this one out.
Stephen Lewis
<plugin-charge>
How could I submit the Charge plugin using Ajax?
# How could I submit the Charge plugin using Ajax?

(Asked by: username_0 on 2017-04-29)

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);
});

**Tags:** plugin-charge

> **Comments:**
> **username_1**: Are you using the Stripe.js checkout option, as detailed in [the Charge documentation](https://squarebit.co.uk/software/craft/charge/usage/quickstart/using-stripe-js)?  
> **username_0**: 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  
> **username_1**: Have you specified the `$.ajax` method? It uses `GET` by default, but you need to submit the form using `POST`.  
> **username_1**: You're welcome. I added my comment as an answer. If you can accept it, then we can close this one out.  

---

## 1 answers

### Answer by username_1 on 2017-04-30. Score: 1 | Accepted answer

You need to specify the HTTP method used by [the `$.ajax` method](http://api.jquery.com/jquery.ajax/).

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


---

