短信验证码倒计时功能(刷新不会重置时间)
首先需要引入的就是jquery文件和jquery.cookie.min.js
js部分:
<script type="text/javascript">
if($.cookie('validateCodeCountdown')>0){
$("#second").prop('disabled', true);
$("#second").text("("+$.cookie('validateCodeCountdown')+"s)后重新发送") ;
setTime($("#second"));
}
$("#second").click(function (){
$.cookie('validateCodeCountdown', 60);
sendyzm($("#second"));
});
//用ajax提交到后台的发送短信接口
function sendyzm(obj){
var mobile= $("#mobile").val();
if(result) {
$.ajax({
url:"你的ajax路径",
data:{mobile:mobile},//你的参数
dataType:"json",
type:"post",
success:function(res){
if(res.message=