码迷,mamicode.com
首页 > Web开发 > 详细

jquery 倒计时 60秒 短信 验证码 js ajax 获取

时间:2018-04-03 10:52:49      阅读:227      评论:0      收藏:0      [点我收藏+]

标签:val   验证码   alert   fun   color   als   form   wait   index   

 

$(function () {

    var wait=60;
    function time( o ){

        if (wait == 0) {
            o.toggleClass(‘bg-lv‘);
            o.removeAttr("disabled");   
            o.val("获取验证码");
            wait = 60;

        } else { 
            o.removeClass(‘bg-lv‘);
            o.attr("disabled",true);
            o.val("重新发送(" + wait + ")");
            wait--;
            setTimeout(function() {
            time(o);
            }, 1000)
        }
    }

    $("#getCode").click(function(){

        var formData = $(‘#form‘).serialize();
        $.ajax({
            url:"{:url(‘login/index‘)}",
            data:formData,
            dataType:"json",
            type:"post",
            success:function(r){
                if(r.check==1){
                    time($("#getCode"));
                    alert(r.msg);
                }else{
                    alert(r.msg);
                }
            }
        })
        return false;
    });  
    
});  

 

jquery 倒计时 60秒 短信 验证码 js ajax 获取

标签:val   验证码   alert   fun   color   als   form   wait   index   

原文地址:https://www.cnblogs.com/shaoing/p/8706426.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!