reCAPTCHA数据回调不工作

reCAPTCHA数据回调不工作

本文介绍了Google reCAPTCHA数据回调不工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经建立了一封电子邮件通讯注册表单,它从我的网站发布到mailchimp。我已将Google reCAPTCHA添加到表单中,并且有一个数据回调,以便在提交按钮最初被禁用时启用它。这在昨天晚上在所有浏览器中正常工作,并做成功测试&签下了就回家了。我在今天早上发现订阅按钮不会启用/ data-callback不工作?陌生..

I have built a email newsletter signup form which posts into mailchimp from my website. I have Google reCAPTCHA added to the form and have a data-callback to enable the submit button as it is initially disabled. This was working fine in all browsers last night and did tests with success & signed off on it..and went home. I got in this morning and found the subscribe button will not enable / data-callback does not work? Strange..

回呼

<div class="g-recaptcha" data-callback="recaptcha_callback" data-sitekey="xxxxx"></div>

在表单底部的输入按钮

<input type="submit" value="Subscribe" name="subscribe" id="mc-embedded-subscribe" class="button" disabled>

脚本

<script src='https://www.google.com/recaptcha/api.js'></script>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script type="text/javascript">
    $(document).ready(function() {
      function recaptcha_callback(){
        alert("callback working");
        $('.button').prop("disabled", false);
      }
    )};
</script>


推荐答案

将脚本更改为...

<script type="text/javascript">
    function recaptcha_callback(){
      alert("callback working");
      $('.button').prop("disabled", false);
    }
</script>

通过将函数放在 document.ready 事件,它不在全局范围内,因此无法通过captcha控件访问。

By placing your function inside the document.ready event, it is not in the global scope and therefore unreachable by the captcha control.

这篇关于Google reCAPTCHA数据回调不工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-02 01:43