[英]How send value of no-captcha (v2) 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:
$.post('index.php', {
hiddenRecaptcha: grecaptcha.getResponse(),
...
我也嘗試:
hiddenRecaptcha: $("#g-recaptcha-response").val(),
從官方參考閱讀; 有3種方法,但是在這里您使用javascript發送,因此請在表單中進行以下更改
PS:請記住腳本順序,否則您將無法獲得驗證碼
為您的Recaptcha分配一個唯一的ID
<div class="g-recaptcha" id="my-recaptcha" data-size="normal"></div>
現在
<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>
在
$.post({'whatever.php',{ 'recaptcha' : recaptcha.getResponse(my_recaptcha_widget)}
});
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.