ajax防止表单重复提交
<div class="btn-wrap">
<div id="btn" class="btn">提交</div>
</div>
$.ajax({
type:'post',
url:'../../../maintain/addConsult',
dataType:'json',
data:{title:title,question:question,check1:check1,check2:check2,id:id},
async:false,
beforeSend: function () {
//1.让提交按钮失效,以实现防止按钮重复点击
$(".btn").attr('disabled', true);
//2.给用户提供友好状态提示
$(".btn").text('提交中...');
},
complete: function () {
//3.让登陆按钮重新有效
$(".btn").removeAttr('disabled');
},
success:function(data){
if(data>0){
//sessionStorage.setItem('jump', 'jump');
window.history.back(-1);
}else{
alert("咨询失败");
}
}
})