ReCAPTCHA couldn't find user-provided function: myCallBack

Sheetal Sharma picture Sheetal Sharma · Jun 15, 2017 · Viewed 41.9k times · Source

I'm trying to use ReCAPTCHA where I am getting following error.

ReCAPTCHA couldn't find user-provided function: myCallBack.

How can I solve this issue?

var verifyCallback3 = function(response) {
    if(response!=null){
        $("#rss").show();
    }
};

var myCallBack = function() {
    grecaptcha.render('html_element', {
        'sitekey' : '6sssfffffffffAAPfEI_RkbAlUuw5FA4p-kiGy5Nea',
        'callback' : verifyCallback3,
        'theme' : 'light',
        'type':'image'
    });
};

Answer

John Lehmann picture John Lehmann · May 11, 2018

Make sure your callback function is being defined in the global scope. For some reason, in production my function was not in this namespace.

In addition to:

function myCallback() { ... }

Make sure you directly assign it into the global space:

window.myCallback = myCallback;

You should be able to test whether this is your problem, my typing the function name at the Javascript console and seeing if it's defined or not.