Google reCAPTCHA数据回调不工作

编程入门 行业动态 更新时间:2024-10-27 12:26:39
本文介绍了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='www.google/recaptcha/api.js'></script> <script src="//ajax.googleapis/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数据回调不工作

本文发布于:2023-06-07 05:58:52,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/568663.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:回调   数据   工作   Google   reCAPTCHA

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!