新的recaptcha在(基本上)同一页面中不能工作两次 [英] New recaptcha doesn't work twice in (basically) the same page

查看:335
本文介绍了新的recaptcha在(基本上)同一页面中不能工作两次的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

对于我的网站,我在一个div中加载所有的子页面,基本上覆盖了一切,但通过jquery的菜单。
结构就是这样的,你按下账户按钮,你就可以得到登录表单,然后有一个链接(会触发一个onclick函数)到注册页面。



我首先通过最简单的方法将验证码引入了注册页面,因为我无法获得任何其他工作。
一切都很好,直到我将captcha添加到登录页面,现在注册页面不会显示它,并且我收到未捕获的错误:ReCAPTCHA占位符元素必须为空错误。



以下是captcha在两页上的加载方式:

 < script src =' https://www.google.com/recaptcha/api.js'></script> 
< div id =captchaclass =g-recaptchadata-sitekey =6LeNGScO _>< / div>

register.php上的相同内容,但是通过echo

这是显示注册页面的函数

 函数goregister()
{
grecaptcha.reset();
page = 4;
var element =#mbody;
var link =/php/register.php;
$(element).load(link);
}

我甚至尝试在captcha div中添加一个id并将其设置为 但它仍然没有帮助。

解决方案

我也有这个错误:



未捕获的错误:ReCAPTCHA占位符元素必须为空



在我的情况下问题是,我导入了库twince。



更确切地说:我的CMS MURA导入了一次库,以提供reCaptcha作为默认服务。我第二次导入了这个库,而不是kowning。


For my website I'm loading all subpages in a div that basically covers everything but the menu via jquery. The structure is like this, you press the account button, and you get the log-in form, then there's a link(that fires an onclick function) to the registration page.

I first introduced the captcha to the reg page, via the easiest method, because I couldn't get anything else to work. Everything was fine, until I added captcha to the log-in page, now the registration page doesn't render it and I get an "Uncaught Error: ReCAPTCHA placeholder element must be empty" error.

Here's how the captcha is loaded on both pages:

<script src='https://www.google.com/recaptcha/api.js'></script>
<div id="captcha" class="g-recaptcha" data-sitekey="6LeNGScO_"></div>   

The same thing on register.php but via echo

this is the function that shows the registration page

function goregister()
{
    grecaptcha.reset();
    page = 4;
    var element = "#mbody";
    var link = "/php/register.php";
    $(element).load(link);
}

I even tried adding an id to the captcha div and setting it's innerhtml to "" but it still won't help.

解决方案

I had this Error too:

Uncaught Error: ReCAPTCHA placeholder element must be empty

in my case the problem was, that I imported the library twince.

More exactly: My CMS MURA imported the library once, to provide reCaptcha as default service. And I imported the library the second time, not kowning.

这篇关于新的recaptcha在(基本上)同一页面中不能工作两次的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆