Google recaptcha v3 recaptcha_response is null

后端 未结 1 1891
终归单人心
终归单人心 2021-01-27 10:20

i am using google recaptcha v3 in my website ,

here is the code i have added in my html web page in the head:

1条回答
  •  野趣味
    野趣味 (楼主)
    2021-01-27 11:13

    i tried lots of changes but everytime i get " token = null " then i try this.. 100% working....

    in Your Html

    
    
    
    
      

    after then add in your js file

    $(document).ready(function(){
      setInterval(function(){
            ReCaptchaCallbackV3();    
        }, 90000);
        
        $(document).on("submit",'#contact',function (e) {
          var token = $('[name="g-recaptcha-response"]').val();
          console.log(token);
        });
    });
    
    var ReCaptchaCallbackV3 = function() {
        grecaptcha.ready(function () {
            grecaptcha.execute('YOUR-SITE-KEY', { action: 'contact' }).then(function (token) {});
        });
    }

    0 讨论(0)
提交回复
热议问题