jQuery Ajax 初始化方法

$.ajaxSetup({
    headers: {
        "Authorization": auth_token
    },
    cache: false, //禁用缓存
    dataType: "json",
    //	contentType: "application/json",
    contentType: 'application/json',
	/**/
    statusCode: {
        404: function() {
            //			alert("page not found");
        },
        401: function() {
            // swal("","登录超时,请重新登录","");
            swal("","登录超时,跳转登录页面,请等待...","");
            $(".sa-button-container .sa-confirm-button-container .confirm").attr("disabled",true);
            setTimeout(function(){
                window.location.href="login.html"
            },2000)

        },
        500: function(result) {
            console.log(result);
            swal("","服务器错误,请联系管理员。","");
        }
    },
    success: function(result) {
        //console.log(result);

    },
    error: function(result) {
        console.log(result);
        // swal("","服务器错误,请联系管理员。","");
    }
});

猜你喜欢

转载自blog.csdn.net/qiuyan_f/article/details/79217228