【发布时间】:2018-04-13 15:55:45
【问题描述】:
我想在没有 onload 回调的情况下呈现 recaptcha 元素。我有一个没有<form> 的页面。他们在保存到数据库之前使用 jquery 从输入字段中获取值,所以我想在保存之前得到响应。
HTML 头部:
<script src='https://www.google.com/recaptcha/api.js'></script>
身体:
<div id="googleQuoteRecapture"></div>
document.ready中的JS:
var widget = document.getElementById('googleQuoteRecapture')
var widgetId1 = grecaptcha.render(widget, {
'sitekey' : 'site_key',
'theme' : 'light'
});
Uncaught ReferenceError: grecaptcha is not defined
目标是grecaptcha.getResponse(widgetId1)
这可能吗?
【问题讨论】:
-
你在哪里定义
grecaptcha? -
@TheIncorrigible1 我认为在头部加载脚本会定义它?
-
我没有在你链接的 api 中看到它的定义。
标签: javascript recaptcha