New recaptcha doesn't work twice in (basically) the same page

做~自己de王妃 提交于 2019-12-10 21:55:27

问题


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.


回答1:


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.



来源:https://stackoverflow.com/questions/28513959/new-recaptcha-doesnt-work-twice-in-basically-the-same-page

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!