Google reCAPTCHA 数据回调不起作用 [英] Google reCAPTCHA data-callback not working

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

问题描述

我已经建立了一个电子邮件通讯注册表格,可以从我的网站发布到 mailchimp.我在表单中添加了 Google reCAPTCHA,并有一个数据回调来启用提交按钮,因为它最初被禁用.昨晚在所有浏览器中都运行良好,并成功进行了测试签了字..然后回家了.我今天早上起来,发现订阅按钮无法启用/数据回调不起作用?奇怪..

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>

推荐答案

将您的脚本更改为...

Change your script to...

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

通过将您的函数放在 document.ready 事件中,它不在全局范围内,因此验证码控件无法访问.

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 数据回调不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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