user3402600 user3402600 - 1 year ago 44
Ajax Question

issue with loading event via ajax

I start calendar with code below:

var calendar = $('#calendar').fullCalendar({
slotDuration: '00:15:00', /* If we want to split day time each 15minutes */
minTime: '00:00:00',
maxTime: '24:00:00',
header: {
left: 'prev,next today',
center: 'title',
right: 'month,agendaWeek,agendaDay'
},
// events: allevents,
events: '/app/Http/Controllers/api/calendarController.php?action=getEvents&calendar_id=<?php echo $calendarid; ?>',
editable: true,
eventStartEditable: true,
droppable: true, // this allows things to be dropped onto the calendar !!!
})


The controller which I am calling will return json similar to:

[
{"id":1,"title":"Test","start":"7-02-2017 15:36","end":"7-02-2017 15:36","className":null,"description":null},
{"id":2,"title":"test","start":"6-02-2017 11:00","end":"6-02-2017 12:00","className":null,"description":null},
{"id":3,"title":"asdadsadasd","start":"30-01-2017 12:00","end":"30-01-2017 12:00","className":"bg-green","description":"asdasdasas"},
{"id":4,"title":"sadsadsa","start":"31-01-2017 12:00","end":"31-01-2017 13:00","className":"bg-blue","description":"asasds"}
]


The problem is that for some reason data are not shown on the calendar?

Thanks for any answers.




Extra note: I am running FullCalendar v2.0.0-beta2

Answer Source

I just tested it myself with the data you gave me and they are showing up just in the wrong place. You think you are putting the date in D/MM/YYYY format but full calendar is reading it as M/DD/YYYY. Change the format to MM/DD/YYYY and it works fine. The JSON you posted would look like this

[
  {"id":1,"title":"Test","start":"02-07-2017 15:36","end":"02-07-2017 15:36","className":null,"description":null},
  {"id":2,"title":"test","start":"02-06-2017 11:00","end":"02-06-2017 12:00","className":null,"description":null},
  {"id":3,"title":"asdadsadasd","start":"01-30-2017 12:00","end":"01-30-2017 12:00","className":"bg-green","description":"asdasdasas"},
  {"id":4,"title":"sadsadsa","start":"01-31-2017 12:00","end":"01-31-2017 13:00","className":"bg-blue","description":"asasds"}
]
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download