简体   繁体   English

成功进行表单验证后,如何获取我的Ajax表单以将验证码验证注入浏览器?

[英]How do get my ajax form to inject captcha verification into the browser after successful form validation?

Currently after my form has passed validation it forwards to an html page. 目前,在我的表单通过验证之后,它会转发到html页面。

I would like to have one last step that pulls reCaptcha and when reCaptcha has been passed only then is the registration details of the user sent to my database and user forwarded to what ever page I choose. 我想最后一步是提取reCaptcha,只有在通过reCaptcha时,才将用户的注册详细信息发送到我的数据库,并将用户转发到我选择的页面。

Please advise me on the best way to do this thanks. 请为我提供最好的建议方法,谢谢。

Here is my javascript and ajax. 这是我的JavaScript和Ajax。 The submit.php is a file that holds all my validation rules. Submit.php是一个保存我所有验证规则的文件。 I think I now have to have a file that holds my captcha and use ajax to get that file or maybe there is some better way. 我想我现在必须拥有一个保存验证码并使用ajax来获取该文件的文件,或者也许有更好的方法。 I'm still learning. 我还在学习。

$(document).ready(function(){

        $('#fhjoinForm').submit(function(e) {

            register();
            e.preventDefault();

        });

    });


    function register()
    {
        hideshow('loading',1);
        error(0);

        $.ajax({
            type: "POST",
            url: "submit.php",
            data: $('#fhjoinForm').serialize(),
            dataType: "json",
            success: function(msg){

                if(parseInt(msg.status)==1)
                {
                    window.location=msg.txt;
                }
                else if(parseInt(msg.status)==0)
                {
                    error(1,msg.txt);
                }

                hideshow('loading',0);
            }
        });

    }


    function hideshow(el,act)
    {
        if(act) $('#'+el).css('visibility','visible');
        else $('#'+el).css('visibility','hidden');
    }

    function error(act,txt)
    {
        hideshow('error',act);
        if(txt) $('#error').html(txt);
    }

因此,必须有一种简便的方法可以将reCaotcha添加为我的注册表单的最后一步,然后再提交。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM