<a href="javascript:;" id="sendToTel" >发送短信</a> <script type="text/javascript">
$(document).ready(function () {
$("#sendToTel").click(function () {
var mobile = $("#txtMobile").val();
$.ajax({
type: "POST",
url: "/Ajax/SmsAddress.ashx",
data: "Mobile=" + mobile + "",
dataType: "text",
success: function (msg) {
$("#sendToTel").html("<i>发送成功</i>");
//在这里禁用30秒 然后才可以重新点
}
});
}); var canSend;
function updateTime(time) {
var linkBtn = $("#sendToTel");
linkBtn.html(time <= 0 ? "<i>发送短信</i>" : ("<i>" + time + "秒后可重新发送</i>"));
var hander = setInterval(function () {
if (time <= 0) {
canSend = false;
clearInterval(hander);
linkBtn.html("<i>发送短信</i>");
linkBtn.removeAttr("disabled");
}
else {
canSend = true;
linkBtn.attr({ "disabled": "disabled" });
linkBtn.html("<i>" + time + "秒后可重新发送</i>");
}
}, 1000);
}
});
</script>