Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Problems using FullCalendar with ajax

I'm using FullCalendar 2.2.3 and I want to update the DB when users modify any of its events. This is the definition of the calendar:

$('#calendar').fullCalendar({
    firstDay: 1,
    timezone: 'Europe/Madrid',
    allDayDefault: false,
    theme: false,
    aspectRatio: 2.2,
    timeFormat: 'H:mm',
    header: {
        left: '',
        center: 'title',
        right: 'today prev,next'
    },
    editable: false,
    eventMouseover: function(event, jsEvent, view) {
            if (view.name !== 'agendaDay') {
                    $(jsEvent.target).attr('title', event.title);
            }
    },
    events: {
        url: '/getEvents.php',
        type: 'POST',
        cache: false,
        error: function() {
            // error
        },
    },
    eventDrop: function(event, delta, revertFunc) {
        if (!confirm("Are you sure about this change?")) {
            revertFunc();
        }
    }       
});

This works fine, but when I change eventDrop to update the DB

eventDrop: function(event, delta, revertFunc) {
    var parameters = {
        "idevento" : event.id,
        "fecha"    : event.start
    };
    $.ajax({
        type: "POST",
        data: parameters,
        url: '/cambiarFechaEventoUsuario.php',
        success: function(data) {
            var res = jQuery.parseJSON(data);
            if (res.error == 0) {
                alert('OK');
            }
            else {
                alert('No OK');
            }
        },
        error: function(e) {
            alert('Server error');
        }
    });
}

I get the following error:

TypeError: this._ordinalParse is undefined

moment.min.js (línea 6, col 17468)

Also, if I use the file "es.js" (I'm spanish), I get a different error:

TypeError: e is undefined

es.js (línea 1, col 453)

I haven't changed anything about either of these two js files, obviously.

Does anyone know how to fix this?

Thanks in advance and sorry for my english :(

like image 394
DandyCC Avatar asked Oct 20 '22 21:10

DandyCC


1 Answers

I just found out the solution. If anyone has the same problem, the error comes from the date format.

event.start.format("YYYY-MM-DD")

Just changing the date format works perfectly.

like image 187
DandyCC Avatar answered Oct 27 '22 20:10

DandyCC