I am using ReCAPTCHA version V2. On the callback function (i.e. data-callback), I am getting the following error message.
ReCAPTCHA couldn't find user-provided function: function (response)
Now, most of the posts/solutions I see on the web are related to a local callback function that doesn't get invoked when referred in data-callback attribute of the g-recaptcha div. However, in my case, even the inline function does not get invoked. Please have a look at the following image.
In fact, when I am using JavaScript native function such as alert(), it is still not working.
Here's the JS code I am using.
<script src='https://www.google.com/recaptcha/api.js'></script>
First try - callback function:
<div class="g-recaptcha" data-sitekey="Please add your site key if you want to test" data-callback="function (response) { alert('working: ', response);}"></div>
Second try - callback function:
<div class="g-recaptcha" data-sitekey="Please add your site key if you want to test" data-callback="Window.alert('hi');"></div>
I appreciate your help if you can help me understand why is the google API responding in a completely weird way.


window.alert('hi')is a function call that belongs to a function body. Try to create a function with that code inside and add that function name there. - Christos Lytraswindow[Window.alert('hi');]or thiswindow[function (resp...and it doesn't get inline functions like that. There is an old method to write functions inside html attributes usingjs: ...but it's obsolete and you should just declare a normal function and then use just it's name. Rememberdata-callbackis not an event attribute, it's just a data attribute that it's value is used to call a function. - Christos Lytras