1. 程式人生 > >jquery 倒計時 60秒 短信 驗證碼 js ajax 獲取

jquery 倒計時 60秒 短信 驗證碼 js ajax 獲取

mov bsp dex style getc AI time UC LV

$(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 獲取