[英]How send value of no-captcha (v2) to another page with jQuery?
How send value of recaptcha to another page with jQuery? 如何使用jQuery将Recaptcha的值发送到另一个页面?
<head>
<script src='https://www.google.com/recaptcha/api.js'></script>
</head>
<body>
...
<form>
<div class="g-recaptcha" data-size="normal" data-sitekey="xxxxxxxxxxxx"></div>
<input type="sumbit" />
</form>
JS: JS:
$.post('index.php', {
hiddenRecaptcha: grecaptcha.getResponse(),
...
I also try: 我也尝试:
hiddenRecaptcha: $("#g-recaptcha-response").val(),
read from official reference ; 从官方参考阅读; there are 3 ways but here you are sending with javascript so make below changes in your form
有3种方法,但是在这里您使用javascript发送,因此请在表单中进行以下更改
PS: remember the script order otherwise you will not get the recaptcha PS:请记住脚本顺序,否则您将无法获得验证码
assign a unique id to your div of recaptcha 为您的Recaptcha分配一个唯一的ID
<div class="g-recaptcha" id="my-recaptcha" data-size="normal"></div>
now 现在
<script type="text/javascript">
var my_recaptcha_widget;
var onloadCallback = function() {
if($('#my-recaptcha').length) {
my_recaptcha_widget = grecaptcha.render('my-recaptcha', {
'sitekey' : '6LfbhhQTAAXXXXXXXXXXXXXCJlFajw'
});
}
};
</script>
<script src="https://www.google.com/recaptcha/api.js?onload=onloadCallback&render=explicit" async defer></script>
in 在
$.post({'whatever.php',{ 'recaptcha' : recaptcha.getResponse(my_recaptcha_widget)}
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.