Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
104
rated 0 times [  106] [ 2]  / answers: 1 / hits: 102009  / 9 Years ago, thu, april 23, 2015, 12:00:00

I am using recaptcha v2



I am getting the following error occasionally (sometimes i don't get error and sometimes i do get it)



Uncaught ReferenceError: grecaptcha is not defined


It seems because of the internal http request. that takes some time to get another js recaptcha__en.js. Meanwhile actual rendering code of grecaptcha executes.



So what is the standard solution to avoid this issue.?



PS : of course i am looking for some solution other than setTimeout


More From » recaptcha

 Answers
163

Recaptcha has a onload callback that will run once recaptcha is loaded. Place your code inside that callback function.



https://developers.google.com/recaptcha/docs/display



<script>
function onloadCallback() {
/* Place your recaptcha rendering code here */
}
</script>
<script src=https://www.google.com/recaptcha/api.js?onload=onloadCallback&render=explicit></script>

[#66936] Wednesday, April 22, 2015, 9 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
ravenl

Total Points: 338
Total Questions: 107
Total Answers: 112

Location: Belize
Member since Mon, Jun 20, 2022
2 Years ago
ravenl questions
Thu, Feb 18, 21, 00:00, 3 Years ago
Tue, Jan 12, 21, 00:00, 3 Years ago
Tue, Mar 17, 20, 00:00, 4 Years ago
;