DarkGhostHunter / Captchavel

Integrate reCAPTCHA into your Laravel app better than the Big G itself!
MIT License
95 stars 17 forks source link

AJAX issues #11

Closed thursdaydan closed 5 years ago

thursdaydan commented 5 years ago

HI!, Not sure if this is the right place for this sort of thing but I was wondering how I would get this working with a form submitted using ajax?

I keep receiving the following respose The reCAPTCHA token received is invalid

When I submit the form in the traditional way it sends the correct response, so was just wondering what I need to do to get this working.

DarkGhostHunter commented 5 years ago

It really depends on how you're pushing the form to the page.

That error arises when the token of the reCAPTCHA challenge isn't sent by the request to the app, for whatever reason.

For the looks of it, you will have to manually load the script from Google and add it to the forms needed, since the default script is unable to do it in your site. This tend to happen when you submit something entirely in JS, or using Virtual DOM (like Vue or React).

thursdaydan commented 5 years ago

Thanks for your reply and pointing me in the right direction! Sorry if this wasn't the appropriate place for the question, just wasn't 100% clear to me in the documentation what the proper method was for utilising this in an AJAX based form.

DarkGhostHunter commented 5 years ago

I just may add it then.