ajax按钮倒计时代码
发布时间:2020-12-16 03:30:01 所属栏目:百科 来源:网络整理
导读:var wait = 60; get_code_time = function (o) { if (wait == 0) { o.removeAttribute("disabled"); o.value = "免费获取验证码"; wait = 60; } else { o.setAttribute("disabled",true); o.value = "(" + wait + ")秒后重新获取"; wait--; setTimeout(funct
var wait = 60;
get_code_time = function (o) {
if (wait == 0) {
o.removeAttribute("disabled");
o.value = "免费获取验证码";
wait = 60;
} else {
o.setAttribute("disabled",true);
o.value = "(" + wait + ")秒后重新获取";
wait--;
setTimeout(function() {
get_code_time(o)
},1000)
}
}
获取手机短信之后调用get_code_time函数代码 //重新获取验证码 var o = this;
$.ajax({
url:"Tea_sendCode.action?jsoncallback=?",type:"post",data: {accountId:accountId},dataType: "json",success: function (data) {
if(data.status == 1 && data.code == 200){
alert("验证码已发送至您的手机");
get_code_time(o);
} else {
if(data.msg != ""){
alert(data.msg);
} else {
alert("短信验证码发送失败");
}
}
},error: function (data) {
if(data.status == 0) {
alert(data.msg);
} else {
alert("短信验证码发送失败");
}
}
});
}); (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
