N
N
Name2022-01-11 13:42:04
reCAPTCHA
Name, 2022-01-11 13:42:04

Why doesn't google reCaptcha (Uncaught (in promise) TypeError) work the second time?

When passing the captcha, the following event is triggered:

var onSuccess = function(response)  {
...
}

if the page is not refreshed and the captcha is passed again, then the event will not work, it will show
an Uncaught (in promise) TypeError error

How to make it possible to call the captcha many times without refreshing the page and execute the script after passing the captcha?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
N
Name, 2022-01-26
@User782

maybe someone will come in handy.
create a captcha like this (if the script is loaded simultaneously with the creation of the captcha, then you need to postpone the creation of the captcha for 2-3 seconds):
postpone for three seconds:

setTimeout( function(){
widgetId = grecaptcha.render('recaptchacontainer', {
          'sitekey' : 'sitekey'         
        }) }, 3000);

or do not postpone for three seconds:
widgetId = grecaptcha.render('recaptchacontainer', {
          'sitekey' : 'sitekey'         
        }) }

in html we insert: in js we put the answer into a variable like this: there are no more such problems, you don’t need to reset the captcha.
<div id="recaptchacontainer"></div>
var res = grecaptcha.getResponse(widgetId);

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question