Google Recaptcha无法在CakePHP中使用按钮类型

问题描述

我正在以cakePHP形式实现google recaptcha v2。问题是,如果我将按钮的类型保持为button,则在$this->request->data['g-recaptcha-response']中将得到空值。如果按钮类型是提交,那么我将无法调用函数。因此,必须将按钮类型设置为button

这就是我实现Recaptcha的方式。

    <PHP echo $this->Html->script('https://www.google.com/recaptcha/api.js'); ?>
    <div class="g-recaptcha" style="padding: 5px;" data-sitekey="<?PHP echo Configure::read('Recaptcha.SiteKey'); ?>">
<button class="site-btn modal-btn" type="submit" onclick="loginform()">Submit</button>

使用按钮类型提交,我无法调用loginform()函数,并且无法发出AJAX请求。

请帮助。

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)