表单:
<input type="text" id="code" name="code" placeholder="验证码" class="input-xfat input-xlarge" style="width:120px">
<button type="button" class="btn-xlarge" id="dyMobileButton">发送验证码</button>
<script src="https://cdn.staticfile.org/jquery/1.10.2/jquery.min.js"></script>
$('#dyMobileButton').click(function (){
var tel=$('#phone').val();
var time=60;
// 设置定时器
var timer=setInterval(function (){
time--;
if(time>0){
// 正在倒计时
$('#dyMobileButton').html('重新发送:'+time+'秒');
$('#dyMobileButton').prop('disable',true);
}else{
// 停止倒计时
$('#dyMobileButton').html('发送验证码');
$('#dyMobileButton').prop('disable',false);
clearInterval(timer);
}
},1000)
$.ajax({
url:"getPhone",
data:{tel:tel},
type:'get',
dataType:'json',
success:function(e){
console.log(e);
}});
})