我正在运行一个脚本来获取reCaptcha V3值以验证表单。
<!-- reCaptcha -->
<script src='https://www.google.com/recaptcha/api.js?render=<?php echo $user::PUBLIC_KEY; ?>'></script>
<script>
grecaptcha.ready(function() {
grecaptcha.execute('<?php echo $user::PUBLIC_KEY; ?>', {action: 'login'})
.then(function(token) {
$('<input>').attr({
type: 'hidden',
name: 'g-recaptcha-response',
value: token
}).prependTo('#login-form');
});
});
</script>
我在控制台中得到了这个
Uncaught (in promise) null
Promise.then (async)
then @ recaptcha__en.js:512
(anonymous) @ login.php:121
Yb @ recaptcha__en.js:501
UF @ recaptcha__en.js:498
(anonymous) @ recaptcha__en.js:513
(anonymous) @ recaptcha__en.js:532
这仅发生在我的本地主机上,而不发生在我的共享主机上。