获取fullcalendar事件时如何获取ajax调用返回码

问题描述

我有这个完整的日历定义:

            $('[data-toggle="calendar"]').fullCalendar({
                    themeSystem: 'bootstrap4',locale: 'es',monthNames: ['Enero','Febrero','Marzo','Abril','Mayo','Junio','Julio','Agosto','Septiembre','Octubre','Noviembre','Diciembre'],monthNamesShort: ['Ene','Feb','Mar','Abr','May','Jun','Jul','Ago','Sep','Oct','Nov','Dic'],dayNames: ['Domingo','Lunes','Martes','Miércoles','Jueves','Viernes','Sábado'],dayNamesShort: ['Dom','Lun','Mié','Jue','Vie','Sáb'],header: {
                        left: 'title',center: '',right: 'prev,next today'
                    },buttonText: {
                        today: 'Hoy',month: 'Mes',week: 'Semana',day: 'Día'
                    },displayEventTime: false,events: '/myURL',eventRender: function (eventObj,$el) {
                        $el.popover({
                            title: 'Menú ' + eventObj.title,content: eventObj.description.replace(/\n/g,'<br>'),trigger: 'hover',placement: 'top',container: 'body',html: true
                        });
                    },});

注意 events 的定义。它使用 ajax 调用调用方法。这里的问题是 ajax 调用可以返回禁止错误代码。发生这种情况时,会使用响应标头 (X-Responded-JSON) 发送该错误代码

我需要能够做这样的事情:

function checkUserSession(xhr) {
    // Si es 401,es porque se debe redireccionar al login
    var response = xhr && typeof xhr.getResponseHeader === 'function' ? xhr.getResponseHeader("X-Responded-JSON") : null;
    if (response !== null) {
        var obj = JSON.parse(response);
        if (obj.status === 401) {
            //var href = obj.headers.location;
            //href = obj.headers.location.substr(0,obj.headers.location.indexOf('?ReturnUrl=') + 11) + '/' + location.pathname;
            redirectToLogin();
            return false;
        }
    }

    return true;
}

也就是说,我需要从ajax调用获取返回的XHR对象。我在执行其他 ajax 调用时会这样做,但我还没有在 fullcalendar 插件中找到这样做的方法

问候 詹姆

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)