admin管理员组文章数量:1185646
I implement the reCAPTCHA in this tutorial,
/
which work well for the first time submit. The problems I have are:
I send the captcha with other form data e.g. username , email etc.... so if captcha is correct but other not , the user will send it again, but the second time it return "{ "success": false }"
if I idle it for ~2 min , it will session expire and if I select the box it pop up alert and warning something like " can not refresh : invalid parameter", and I can not select the box again
How to fix those problem? Thanks a lot.
I implement the reCAPTCHA in this tutorial,
https://codeforgeek.com/2014/12/google-recaptcha-tutorial/
which work well for the first time submit. The problems I have are:
I send the captcha with other form data e.g. username , email etc.... so if captcha is correct but other not , the user will send it again, but the second time it return "{ "success": false }"
if I idle it for ~2 min , it will session expire and if I select the box it pop up alert and warning something like " can not refresh : invalid parameter", and I can not select the box again
How to fix those problem? Thanks a lot.
Share Improve this question edited Jun 23, 2015 at 8:34 Rory McCrossan 337k41 gold badges319 silver badges350 bronze badges asked Jun 23, 2015 at 6:06 user3538235user3538235 2,0096 gold badges28 silver badges55 bronze badges2 Answers
Reset to default 27Google reCAPTCHA gives these two functions: I always use this in all my AJAX powered forms.
grecaptcha.getResponse()
grecaptcha.reset();
For both of your problems, use the second function whenever you need in your JavaScript code.
Remember this works if you have only one CAPTCHA in your page. If you have more than two CAPTCHAs use their IDs as explained in Google Docs
https://developers.google.com/recaptcha/docs/display#js_api
Those who have the same problem and meet this topic during research; If you experience problem when you render the captcha automatically, try to render it explicitly. In order to do this, add following code inside body tag.
<script src="https://www.google.com/recaptcha/api.js?onload=recaptchaCallback&render=explicit&hl=tr" async defer></script>
-
var recaptchaCallback = function () { // alert("grecaptcha is ready!"); grecaptcha.render("YOUR HTML DIV ID", { 'sitekey': 'YOUR SITE KEY', }); };
I'm using AJAX to check registration form and get response. So I have added reset function to my AJAX response.
$('#frmRegistration').submit(function () { $.ajax({ url: "_ajax/_ajaxRegistration.php", type: "POST", data: $('#frmRegistration').serialize(), success: function (reply) { $('#resultRegistration').html(reply); grecaptcha.reset(); } }); });
Reference Google reCaptcha explicit render.
本文标签: javascriptGoogle reCAPTCHA fail for second time submitStack Overflow
版权声明:本文标题:javascript - Google reCAPTCHA fail for second time submit - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1738324356a2074651.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论