ajax 不管成功还是失败都会调用的函数 complete

 $.ajax({
        url: '/my/userinfo',
        method: 'get',
        success: function(res) {
            if(res.status !==0) {
                return layui.layer.msg(res.message);
            }
            
            renderAvatar(res.data)
        },
        complete: function(res) {
            const { status, message } = res.responseJSON;
            if(status ===1&&message === '身份认证失败') {
                location.href = '/login.html'
            }
        }
    })

不管成功还是失败都会调用complete 函数

posted @ 2021-03-16 23:57  天使佳少  阅读(940)  评论(0)    收藏  举报