6

I can't for the life of me figure out what I'm doing wrong here. The loaded() callback should fire but does not. Here's the code for a reduced test case (with a JS fiddle link below):

<script> function loaded() { alert('loaded() triggered.'); } </script> <script src="https://www.google.com/recaptcha/api.js?onload=loaded" async defer></script>

https://jsfiddle.net/48dshrew/

ReCaptcha Documentation

1 Answer 1

11

Looks like the render mode needs to be set to 'explicit' for reCaptcha to call your custom onload callback function. Try this:

var onloadCallback = function() { console.log('loaded() triggered.'); }
<script src="https://www.google.com/recaptcha/api.js?onload=onloadCallback&render=explicit" async defer> </script>

Sign up to request clarification or add additional context in comments.

1 Comment

That was it, thanks! Google doesn't mention it in their documentation but that's good to know.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.