Monday, June 3, 2024
 Popular · Latest · Hot · Upcoming
21
rated 0 times [  25] [ 4]  / answers: 1 / hits: 46955  / 9 Years ago, fri, may 15, 2015, 12:00:00

From the documentation I understood that in order to change the language of the recaptcha I have to render it explicitly.



The problem is, however, that it's not really showing up, and the onload is not even called.

When I try to render it automatically it does work.



Here's the code:

In the HTML head: (I have also tried putting this at the end of the body tag)



<script src=https://www.google.com/recaptcha/api.js?onload=recaptchaCallback&render=explicit&hl=iw async defer></script>


In the HTML form:



<div id=recaptcha></div>


Javascript:



var recaptchaCallback = function() {
console.log('recaptcha is ready'); // not showing
grecaptcha.render(recaptcha, {
sitekey: 'My Site Key',
callback: function() {
console.log('recaptcha callback');
}
});
}

More From » html

 Answers
22

I just copied your code, used my own Site Key and it works.



The code I used is:



<html>
<body>
<p>ReCaptcha Test</p>

<div id=recaptcha></div>

<script src=https://www.google.com/recaptcha/api.js?onload=recaptchaCallback&render=explicit&hl=iw async defer></script>

<script type=text/javascript>
var recaptchaCallback = function () {
console.log('recaptcha is ready'); // showing
grecaptcha.render(recaptcha, {
sitekey: 'SITE_KEY',
callback: function () {
console.log('recaptcha callback');
}
});
}
</script>

</body>
</html>


Check your code carefully, as just a single character typo can stop things from working.


[#66592] Wednesday, May 13, 2015, 9 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
briannar

Total Points: 354
Total Questions: 103
Total Answers: 101

Location: Japan
Member since Sat, Jun 6, 2020
4 Years ago
briannar questions
Tue, Aug 31, 21, 00:00, 3 Years ago
Sat, Jun 26, 21, 00:00, 3 Years ago
Sat, Jun 20, 20, 00:00, 4 Years ago
Tue, Apr 7, 20, 00:00, 4 Years ago
;