2017-02-07 89 views
0

裝載事件中,我開始日曆下面的代碼:問題通過AJAX

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-β2

+0

您是否收到任何javascript錯誤? –

+0

沒有在javascript控制檯 – user3402600

+0

我可以看到實際的json是當你去那個網址時返回? –

回答

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"} 
] 
+0

是的,這是由於日期...我結束了使用標準的MySQL日期時間和fullcalendar處理它。 – user3402600

+0

太棒了,很高興我能夠提供幫助 –