function getcode() {
var phone = $('#phoneTF').val();
if (!phone) {
alert('请输入您的手机号码!');
return false;
}
var telRegexp = /^(1[3|4|5|7|8])[\d]{9}$/;
if (!telRegexp.test(phone)) {
alert('请输入正确手机号码!');
return false;
}
$.ajax({
url: "http://bbs.haotoufa.com/xxx.php?tel=" + phone,
datatype: "json",
type: 'get',
success: function (data) { //成功后回调
var d = $.parseJSON(data);
if (d["status"] == 0) {
alert(d["msg"]);
} else {
// 将button和该方法接触binding
$('.codeBtn').attr('disabled', 'disabled');
var timeCount = 59;
var timeout = setInterval(function () {
$('.codeBtn').text('重新发送(' + timeCount-- + ')');
if (timeCount == 0){
clearInterval(timeout);
$('.codeBtn').text('重新发送');
// 将button绑定该方法
$('.codeBtn').attr('disabled', false);
}
}, 1000);
}
},
error: function(){ //失败后回调
}
});
}
网友评论