欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

jquery ajax的success回調(diào)函數(shù)中實(shí)現(xiàn)按鈕置灰倒計(jì)時(shí)

 更新時(shí)間:2013年11月19日 17:34:09   作者:  
實(shí)現(xiàn)異步手機(jī)發(fā)送短信成功之后在ajax的success回調(diào)中實(shí)現(xiàn)將發(fā)送按鈕置灰并倒計(jì)時(shí),具體的實(shí)現(xiàn)示例如下,喜歡的朋友可以研究下
主要是實(shí)現(xiàn)異步手機(jī)發(fā)送短信成功之后在ajax的success回調(diào)中實(shí)現(xiàn)將發(fā)送按鈕置灰并倒計(jì)時(shí),剛開始一直報(bào)js錯(cuò)誤,問題可能出在于調(diào)用ajax之后this被更新,隨意在這之前先把this對(duì)象賦給一個(gè)變量就沒問題

按鈕倒計(jì)時(shí)代碼
復(fù)制代碼 代碼如下:

var wait = 60;
get_code_time = function (o) {
if (wait == 0) {
o.removeAttribute("disabled");
o.value = "免費(fèi)獲取驗(yàn)證碼";
wait = 60;
} else {
o.setAttribute("disabled", true);
o.value = "(" + wait + ")秒后重新獲取";
wait--;
setTimeout(function() {
get_code_time(o)
}, 1000)
}
}

獲取手機(jī)短信之后調(diào)用get_code_time函數(shù)代碼
復(fù)制代碼 代碼如下:

//重新獲取驗(yàn)證碼
$('#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("驗(yàn)證碼已發(fā)送至您的手機(jī)");
get_code_time(o);
} else {

if(data.msg != ""){
alert(data.msg);
} else {
alert("短信驗(yàn)證碼發(fā)送失敗");
}
}
},
error: function (data) {
if(data.status == 0) {
alert(data.msg);
} else {
alert("短信驗(yàn)證碼發(fā)送失敗");
}
}
});
});

相關(guān)文章

最新評(píng)論