0

我有编程绑定方法,一旦我点击提交按钮,页面就永远不会显示加载的迹象。我只看到徽章无限重新加载,我的控制台显示重复加载相同的资源,一旦达到明显 reCAPTCHA 认为我是垃圾邮件机器人并让我解决验证码的地步,我解决它们并再次重复该过程,永无止境。

这是我在 reCAPTCHA 之前基于此答案 HTML5 表单验证的代码:

<script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.12.1/jquery-ui.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script>
<script src='https://www.google.com/recaptcha/api.js' async defer></script>
...
<form id='login' role='form' method='post'>
    <div class="form-group">
        <label for='form-user'>Username</label>
        <input type='text' class='form-control' id='form-user' name='form-user' placeholder='Username' required>
    </div>
    <div class="form-group">
        <label for='form-password'>Password</label>
        <input type='password' class='form-control' id='form-password' name='form-password' placeholder='Password' required>
    </div>
    <div class='g-recaptcha' data-sitekey='my-key' data-size='invisible' data-callback='onSubmit'></div>
    <input type='submit' value='Sign In' name='submit-btn' class='btn btn-default'>
</form>
<script>
    $('#login').submit(function (event) {
        event.preventDefault();
        grecaptcha.reset();
        grecaptcha.execute();
    });

    function onSubmit(response) {
        $('#login').submit();
    }
</script>

可能发生什么以及如何解决?我正在verify the origin of reCAPTCHA solutions禁用本地主机。

提前致谢

4

1 回答 1

0

验证码验证发生在onSubmit函数执行之前。这意味着首先有验证码验证,然后你提交表单,然后你再次重置验证码并grecaptcha.execute()再次调用onSubmit函数。一遍又一遍地。

我不知道您在哪里验证,但是对于提供的代码,您只想摆脱那些额外的 recaptcha 执行,所以$('#login').submit()这里没有必要。

于 2018-07-25T09:49:55.187 回答