Google ReCAPTCHA callback not firing

I can't for the life of me figure out what I am doing wrong here. The load () callback should fire, but it doesn't. Here's the code for a minified test case (with a link to the JS script below):

<script>
  function loaded() {
    alert('loaded() triggered.');
  }
</script>

<script src="https://www.google.com/recaptcha/api.js?onload=loaded" async defer></script>
      

Run codeHide result


https://jsfiddle.net/48dshrew/

ReCaptcha Documentation

+3


source to share


1 answer


It looks like the render mode needs to be set to "explicit" for reCaptcha to call your custom onload callback function. Try the following:



var onloadCallback = function() {
     console.log('loaded() triggered.');
}
      

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

Run codeHide result


+7


source







All Articles