小编Gel*_*itu的帖子

Google reCaptcha使用jquery AJAX进行验证

我不知道如何将其应用于我的登录页面,一旦在ajax上成功获得验证码然后提交表单。这是我的html表单(我将动作留空,因为我仍在测试中)

<form action = "" method = "post">
   <input type = "text" id = "email" name = "email">
   <input type = "password" id = "pass" name = "password">
   <div class = "form-group col-lg-6">
       <div class="g-recaptcha" data-sitekey="MY_KEY"></div>
   </div>
   <input type = "button" id = "submit" value = "submit">
</form>
Run Code Online (Sandbox Code Playgroud)

这是我如何理解发送验证码单词的验证码上的ajax ..如果验证码success提交表格,如果failed我会给出一个alert

$('#submit').click(function() {
var captcha = "captcha";
  $.ajax({
    url: "captcha.php",
    method: "post",
    data:{captcha:captcha},
    success:function(data){
    if(data=='success'){
       $('form').submit();
       }
    }
    else{
       alert('captcha failed. try again');
    }
 }); …
Run Code Online (Sandbox Code Playgroud)

php forms ajax jquery recaptcha

0
推荐指数
1
解决办法
8228
查看次数

标签 统计

ajax ×1

forms ×1

jquery ×1

php ×1

recaptcha ×1