`
颖宝blingbling
  • 浏览: 37573 次
  • 性别: Icon_minigender_1
  • 来自: China
文章分类
社区版块
存档分类
最新评论

jQuery ajax设置全局配置

 
阅读更多
$.ajaxSetup({
	dataType : "json",
	contentType : "application/json",
	headers : {
		'Content-Type' : 'application/x-www-form-urlencoded'
	},
	error : function(jqXHR, textStatus, errorThrown) {
		switch (jqXHR.status) {
		case (500):
			layer.alert('服务器系统内部错误', {
				icon : 2
			});
			break;
		case (401):
			layer.alert('未登录', {
				icon : 2
			});
			break;
		case (403):
			layer.alert('无权限执行此操作', {
				icon : 2
			});
			break;
		case (408):
			layer.alert('请求超时', {
				icon : 2
			});
			break;
		default:
			layer.alert('未知错误,请联系管理员', {
				icon : 2
			});
		}
	},
	cache : false
});

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics