zoukankan      html  css  js  c++  java
  • 发送验证码

    方法一:(setInterval)
    
    $("#getCode").on("click", getCodeClick);
    function getCodeClick() {
     $("#getCode").off("click");
     try {
        new common.ajaxRequest({
          url: url+"cmbntUser/getChangePhoneAuthCode?mobilePhone="+ $("#txtMobile").val().trim(),
          type: "POST",
          param: '',
          dataType: "json",
          header: header,
          callBack: function (result) {
            if(result.type =="SUCCESS"){
              var lefttime = 60;
              $("#getCode").attr("disabled", "disabled");
              $("#getCode").html("60秒后重新获取");
              var countDown = setInterval(function () {
                lefttime--;
                $("#getCode").html(lefttime + "秒后重新获取");
                 if (0 == lefttime) {
                   $("#getCode").html("重新获取");
                   $("#getCode").removeAttr("disabled");
                   $("#getCode").on("click", getCodeClick);
                  clearInterval(countDown);
                 }
              }, 1000);
             }else{
               $("#getCode").on("click", getCodeClick);
                   }
          }
       });
     }
      catch (ex) {
         $("#ErrMessage").html("发送短信失败,请稍后再试。");
        $("#ErrMessage").attr("class", "tip textred");
      }
      return false;
    }

    方法二:(setTimeout)

    function setTime(time){
        time --;
        $('#msgCodeBtn').attr('disabled',true).html(time+'秒后重新获取');
        var timeT = setTimeout(function(){
            setTime(time)
    },
    1000); if(time == 0){ $('#msgCodeBtn').removeAttr('disabled').html('重新获取'); clearTimeout(timeT); } } //发送验证码 $('#msgCodeBtn').on('click',function(){ var time = 60; $('#msgCodeBtn').html('60秒后重新获取'); setTime(time); });
  • 相关阅读:
    机器学习算法优秀性:衡量指标
    MapReduce and Pregel
    K-d 树对聚类算法进行预处理
    论文中的算法描述 By 薛磊
    批判性思维《描述性假设》
    论文中的数学符号使用
    HOOK别人的dylib(HOOK cydia里面的插件)
    关于某听书软件的开通20年会员的心路历程
    Aspects 源码学习
    Undefined symbols for architecture arm64(其cpu架构)
  • 原文地址:https://www.cnblogs.com/myyouzi/p/11162000.html
Copyright © 2011-2022 走看看