经常用,又经常记不住,mark一下,以后直接抄:input('lang')])}");'>提交
function operation(form_id,btn_id,url){
$.ajax({
type: 'POST',
url: url,
dataType: 'json',
data: $(form_id).serialize(),
//发送数据前
beforeSend: function(){
// 禁用按钮防止重复提交
$(btn_id).attr({disabled: "disabled"});
//弹出modal框
$('#modal_sm_black_content').html('正在处理,请稍后');
$("#modal_sm_black").modal("show");
},
//成功返回
success: function(data){
setTimeout(function(){
//隐藏modal框
$(btn_id).removeAttr('disabled');
$('#modal_sm_black').modal('hide');
switch(data){
case 'success':
//操作成功,弹出modal框
$('#modal_sm_black_content').html('操作成功');
$("#modal_sm_black").modal("show");
window.location.reload();
break;
}
}, 1);
},
//处理完成
complete: function(){
$(btn_id).removeAttr('disabled');
$('#modal_sm_black').modal('hide');
},
//报错
error: function(data){
console.info("error: " + data.responseText);
}
});
}modal框: