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函数代码
//重新获取验证码
$(‘#codeagain’).click(function() {
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("短信验证码发送失败");
}
}
});
});