The problem of adding to the page later
sercannozenn opened this issue · 2 comments
Greetings,
I use Recaptcha v2 or Recaptcha v3 in my project, depending on the choice of admin.
I have no problem running it on any page.
However, I am having problems when my login screen is added to the page later. My scenario is as follows:
If the user is not logged in, I send an ajax request and get the login view in response to the ajax request. I show the login view to the user in Bootstrap-modal. During the display process (in Login View) for V2
{!! ReCaptcha::htmlScriptTagJsApi() !!}
and {!! ReCaptcha::htmlFormSnippet () !!}
or for V3
{!! htmlScriptTagJsApi ([
'action' => 'submit',
'callback_then' => 'callbackThen',
'callback_catch' => 'callbackCatch'
]) !!}
If I use it, V2 Recaptcha comes, but when the form is submitted, the default_validation_route is not requested.
I have the same problem in V3 as well. There is no request to default_validation_route.
let wID=grecaptcha.render('recaptcha-element');
grecaptcha.reset(wID);
Hi @sercannozenn, I need more details to help you, I didn't understand how you are creating the AJAX response but I'm pretty sure you have (at least) a configuration error. You shouldn't have any error related to default_validation_route
using V2.
Hi @biscolab I solved the problem. I was calling a view later on the page and recaptcha was not working in the view.
For Recaptcha Version2
let wID = grecaptcha.render('recaptcha-element');
grecaptcha.reset(wID);
For Recaptcha Version 3
grecaptcha.ready(function() { grecaptcha.execute('{{ config('recaptcha.api_site_key') }}', {action: 'submit'}).then(function(token) { $('#recaptchaToken').val(token); }); });
I used these codes to trigger the recaptcha again.