jQuery ReCAPTCHA 找不到用户提供的函数:myCallBack

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/44567543/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-26 17:21:35  来源:igfitidea点击:

ReCAPTCHA couldn't find user-provided function: myCallBack

jqueryrecaptcha

提问by Sheetal Sharma

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

我正在尝试使用 ReCAPTCHA,但出现以下错误。

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

ReCAPTCHA 找不到用户提供的函数: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'
    });
};

回答by John Lehmann

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.

您应该能够测试这是否是您的问题,我在 Javascript 控制台输入函数名称并查看它是否已定义。

回答by Qasim

In your recaptcha div, make sure not to use parenthesis in your data-callback.

在您的 recaptcha div 中,确保不要在数据回调中使用括号。

Like so data-callback="yourCallback", rather than data-callback="yourCallback();"

像这样data-callback="yourCallback",而不是data-callback="yourCallback();"

回答by Husnain Shabbir

The same thing happening with me.I have checked my code carefully, every thing is fine but captcha not shown and in console the message is "ReCAPTCHA couldn't find user-provided function: myCallBack" but finally I found that my JavaScript code was is in page load function. I am just put out it from page load function and its working.

同样的事情发生在我身上。我仔细检查了我的代码,一切都很好,但没有显示验证码,控制台中的消息是“ReCAPTCHA 找不到用户提供的函数:myCallBack”但最后我发现我的 JavaScript 代码是在页面加载功能中。我只是从页面加载功能和它的工作中取出它。

回答by Nestor Junior Castellano

You have to put your script function:

你必须把你的脚本函数:

<script> function registerFormCheck()</script>

Before the google script something like this:

在谷歌脚本之前是这样的:

/* First */    <script> function registerFormCheck(){} </script>
/* Second */   <script> src='https://www.google.com/recaptcha/api.js'></script>

This worked for me...

这对我有用...