B
B
Bayda2018-01-24 16:39:57
JavaScript
Bayda, 2018-01-24 16:39:57

Why don't two reCAPTCHA sent via ajax work?

The bottom line is that there are two forms, you need to insert two invisible recaptchas into them and send these two forms via ajax.
HTML code:

<script type="text/javascript" src="/main.js"></script>
<script src="https://www.google.com/recaptcha/api.js?onload=onloadCallback&render=explicit" async defer></script>
<form id="ShoppingCartFormFast">
    <div id="recaptchaFast"></div>
    <input type="button" id="SubmitOrderingFast"  onClick="CheckBeforeSubmit('#ShoppingCartFormFast');" value="отправить" />
</form>

<form id="ShoppingCartFormStandart">
    <div id="recaptchaStandart"></div>
    <input type="button" id="SubmitOrderingStandart"  onClick="CheckBeforeSubmit('#ShoppingCartFormStandart');" value="отправить"  />
</form>


Main.js content:
var captchaFast, captchaStandart,
    onloadCallback = function() {
    mysitekey = 'blabla';
    captchaFast = grecaptcha.render('recaptchaFast', {
        'sitekey' : mysitekey,
        'size' : 'invisible'
    });

    captchaStandart = grecaptcha.render('recaptchaStandart', {
        'sitekey' : mysitekey,
        'size' : 'invisible'
    });
};
//Проверка формы
function CheckBeforeSubmit(form){  
        console.log(grecaptcha.Respnse(captchaFast));
}


However, grecaptcha.Respnse(captchaFast) always returns an empty value. Why ?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question