Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Google ReCAPTCHA callback function not working

I use Google's reCAPTCHA on my website and I'm having problems getting it to call a callback function. After a user has successfully passed the captcha I want to call a function. I use a div with these attributes to render the captcha:

class='g-recaptcha' data-sitekey='keyhere' data-callback='alert(1);'

However, I can't get the alert(1); to trigger, nothing happens when I fill out the captcha. Everything else about the captcha works fine, I just can't get it to call the function. What could I be doing wrong?

like image 972
Just some guy Avatar asked Dec 20 '22 02:12

Just some guy


1 Answers

I haven't used it, so I don't know if this will help, but looking at the few examples online that I can find, it looks like data-callback should be a function name, not the script body:

class='g-recaptcha' data-callback='doSomething'

function doSomething() { alert(1); }
like image 118
Joe Enos Avatar answered Dec 24 '22 00:12

Joe Enos