Original link: http://www.cnblogs.com/xcsn/archive/2013/04/22/3035240.html
<! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">
<script src= "Html/js/jquery-1.4.1.min.js" type= "Text/javascript" ></script>
<script type= "Text/javascript" >
var intervalobj; Timer variable, control time
var count = 5; Interval function, 1 second execution
var curcount;//current number of seconds remaining
function SendMessage () {
Curcount = count;
Set button effect to start timing
$ ("#btnSendCode"). attr ("Disabled", "true");
$ ("#btnSendCode"). Val ("Please enter the verification code in" + Curcount + "seconds);
Intervalobj = Window.setinterval (setremaintime, 1000); Start Timer, execute once in 1 seconds
Send processing data to the background
$.ajax ({
Type: "POST",//Transmit by post
DataType: "Text",//Data format: JSON
URL: ' login.ashx ',//Destination address
Data: "dealtype=" + Dealtype + "&uid=" + uid + "&code=" + code,
Error:function (XMLHttpRequest, Textstatus, Errorthrown) {},
Success:function (msg) {}
});
}
Timer handler function
function Setremaintime () {
if (Curcount = = 0) {
Window.clearinterval (intervalobj);//Stop Timer
$ ("#btnSendCode"). Removeattr ("Disabled");//Enable button
$ ("#btnSendCode"). Val ("Resend Verification Code");
}
else {
curcount--;
$ ("#btnSendCode"). Val ("Please enter the verification code in" + Curcount + "seconds);
}
}
</script>
<body>
<input id= "Btnsendcode" type= "button" value= "Send verification Code" onclick= "SendMessage ()"/></p>
</body>
jquery implementation of the Click button after the countdown effect, more for the implementation of mobile phone verification Code, email Verification Code