时间:2021-07-01 10:21:17 帮助过:13人阅读
$(".form-data").delegate(".send","click",function () { var phone = $("#tel").val(); if (phone == "") { alert('请先填写手机号') $("#tel").css("background-color","#ff2f28"); return false; } $(this).hide(); $.ajax({ url: "/sendsms", type: "get", dataType: 'json', data: {phone: phone }, async: false, success: function (data) { console.log(data) if (data.status == 0) { settime(); } else { alert(data.msg) settime(); } }, error: function () { alert('网络忙'); settime(); } }); }) var countdown = 120; function settime() { if (countdown == 0) { $(".time").attr("class","time hide"); $(".time").text("<em>120</em>s"); $(".send").css('display','block'); countdown = 120; return false; } else { $(".time").removeClass('hide'); $(".time").text("重新发送("+ countdown+"s)"); countdown--; } setTimeout(function () { settime(); }, 1000); }
相关推荐:
js获取短信验证码按钮倒计时代码
js实现短信验证码读秒功能
怎么用php实现短信验证码发送
以上就是js实现获取短信验证码实例的详细内容,更多请关注Gxl网其它相关文章!