jQuery标准的AJAX模板

时间:2023-11-11 23:44:38
$('#saveInformationTemplate_button').on('click', function(){
if(isEmpty($("#name").val())){
layer.msg('【名称】不可为空!'); return;
} var saveInformationTemplate_form = $('#saveInformationTemplate_form').serialize(); $.ajax({
url : 'saveInformationTemplate.do',
type : "post",
dataType : "json",
data : saveInformationTemplate_form,
cache : false,
async : false,
success : function(data, textStatus, jqXHR) {
if ('success' == textStatus) {
debugger;
layer.msg(data.message, {time: 2000, icon:6}); if(1 == data.status){
setTimeout(function(){
window.location.href = 'informationTemplateList.do';
}, 2000);
}
}
},
error : function(XMLHttpRequest, textStatus, errorThrown) {
layer.msg("textStatus = " + textStatus + ", XMLHttpRequest.status = " + XMLHttpRequest.status + ", XMLHttpRequest.readyState = " + XMLHttpRequest.readyState);
}
});
});