谷歌验证码自动加载

Google Captcha AutoLoad

本文关键字:加载 验证 谷歌      更新时间:2023-09-26

我有关于谷歌验证码自动加载的问题。谷歌验证码根据onclick函数给了我源代码,但我在Javascript中很弱,不能在自动加载函数中修改。有人能指导我如何改变自动加载功能时,页面加载验证码自动显示?重要的是,我使用的是fanybox ajax选项,这就是为什么我有一些复杂性。上面提到的代码:

<script type="text/javascript" src="http://www.google.com/recaptcha/api/js/recaptcha_ajax.js"></script>
<script type="text/javascript">
function showRecaptcha() {
        Recaptcha.create("6Lcxj-ASAAAAAJ-OV2Sw40GfzbODQNLOTKuEFPbU", 'captchadiv', {
        tabindex: 1,
        theme: "clean",
        callback: Recaptcha.focus_response_field
        });
}     
</script>
<div id="captchadiv"></div>
<input type="button" value="Change reCAPTCHA" onclick="showRecaptcha('captcha_div');"></input>

在ajax中输入recapcha .reload(),如下所示

 $.ajax({ 
         type: 'POST', 
         url: "../yourpath", 
         data: $("#signupForm").serialize(), 
         datatype: "json", 
         success: function (response) {
             alert(response.message);
             if(response.message=="Captcha invalid"){
                   Recaptcha.reload();
                             }
         }, 
         error:  function(response, ajaxOptions, thrownError) {
             alert("Some problem in saving the record : " + response.message);
         }
    });