[英]Reload reCaptcha after ajaxComplete
My reCaptcha is not reloading when ajaxComplete event complete.当 ajaxComplete 事件完成时,我的 reCaptcha 没有重新加载。
I have a console error: "No reCAPTCHA clients exist."我有一个控制台错误:“不存在 reCAPTCHA 客户端。” So why my reCaptcha client disappeared after ajaxComplete?
那么为什么我的 reCaptcha 客户端在 ajaxComplete 之后消失了呢?
Here is my sample code:这是我的示例代码:
$(document).ajaxComplete(function (event, request, settings) {
grecaptcha.reset(); });
Adding the grecaptcha.render('recaptchaId');
添加
grecaptcha.render('recaptchaId');
solved the problem. 解决了这个问题。
So, the updated code is: 因此,更新的代码是:
$(document).ajaxComplete(function (event, request, settings) {
grecaptcha.render('recaptchaWıdgetId'); });
The problem is clearly stated in the exception.异常中清楚地说明了问题。 You need to render reCaptcha on the page with
grecaptcha.render
:您需要使用 grecaptcha.render 在页面上呈现
grecaptcha.render
:
var domId = 'recaptchaId';
grecaptcha.render(domId, {"sitekey": "YOUR_CAPTCHA_ID", size: 'invisible'});
In my case error came from minified code:在我的例子中,错误来自缩小代码:
if (y[6](57).contains(window.___grecaptcha_cfg.clients[P].Ci)){
Y=P;
break a
}
throw Error("No reCAPTCHA clients exist.");
and window.___grecaptcha_cfg.clients
was empty till I fixed the order: render
is called before execute
.和
window.___grecaptcha_cfg.clients
是空的,直到我确定了顺序: render
在execute
之前被调用。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.