How send value of recaptcha to another page with jQuery?
<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(),
...
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
PS: remember the script order otherwise you will not get the recaptcha
assign a unique id to your div of recaptcha
<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)}
});
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.