I'm trying to migrate from using Google reCaptcha v2 to the invisible reCaptcha. I use Parsley.js for form validation and submit the form using the Malsup Ajax form plugin. my current code looks like this :
HTML:
<form action="send1.php" method="post" class="contact_form">
<label for="name_1">Name</label>
<input type="text" name="name_1" id="name_1" value="" required />
<div class="g-recaptcha" data-sitekey="XXX"></div>
<input type="submit" class="button" value="">
</form>
JS:
$('.contact_form').parsley();
$('.contact_form').submit(function(){
if($('.contact_form').parsley().validate()){
$('.contact_form').ajaxSubmit();
}
return false;
});
this successfully passes a g-recaptcha-response to send1.php, where the reCaptcha is validated.
How can i integrate Invisible reCaptcha with this script?
i tried using this:
<div id='recaptcha' class="g-recaptcha"
data-sitekey="XXX"
data-callback="onSubmit"
data-size="invisible"></div>
</div>
But I'm not sure how to use the data-callback. If I add
grecaptcha.execute();
Before the ajaxSubmit() then the field g-recaptcha-response is added to the Ajax call, but it's value is blank...
Any help, please?