通过ajax加载事件的问题

时间:2017-02-07 17:59:51

标签: jquery ajax fullcalendar

我使用以下代码开始日历:

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 !!!
})

我正在调用的控制器将返回类似于:

的json
 [
    {"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"}
]

问题在于,由于某些原因,数据未显示在日历上?

感谢您的回答。

额外注意:我正在运行FullCalendar v2.0.0-beta2

1 个答案:

答案 0 :(得分:0)

我刚刚用你给我的数据进行了测试,他们出现在错误的地方。您认为您将日期设置为D/MM/YYYY格式,但完整日历将其显示为M/DD/YYYY。将格式更改为MM/DD/YYYY,它可以正常工作。您发布的JSON看起来像这样

[
  {"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"}
]