jQuery标准的AJAX模板

$('#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);
		}
	});
});

  

posted @ 2017-01-05 12:37  hapday  阅读(6158)  评论(1编辑  收藏  举报