如何解决获取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 举报,一经查实,本站将立刻删除。