I've seen many post about fullcalendar here but none did solve my problem. I'm trying to load events from an external php file (JSON feed). Events aren't rendered in the calendar.
So here is my javascript code:
<script>
$(document).ready(function() {
var calendar = $('#calendar').fullCalendar({
defaultView: 'agendaWeek',
allDaySlot: false,
minTime: 8,
maxTime: 17,
defaultEventMinutes: 30,
weekends: false,
selectable: true,
selectHelper: true,
select: function(start, end, allDay) {
if (confirm("Voulez-vous réserver cette période?")) {
$('#idMedecin').val('<?php echo $_SESSION["idMedecin"]; ?>');
$('#idPatient').val('<?php echo $patient->numero; ?>');
$('#eventS').val(start);
$('#eventE').val(end);
$('#calendarForm').submit();
}
},
events: {
url: 'calendrier-feed.php',
type: 'POST',
data: {
idMedecin: '<?php echo $_SESSION["idMedecin"]; ?>'
},
error: function() {
alert('there was an error while fetching events!');
}
}
});
});
</script>
<div id="calendar">
</div>
And this is what I have in my calendar-feed.php:
getAllEvents($doc); foreach($liste as $event) { $event_arr = array(); $event_arr['id'] = $event->id; $event_arr['title'] = $event->patient; $event_arr['start'] = $event->start; $event_arr['end'] = $event->end; array_push($return_arr, $event_arr); } echo json_encode($return_arr); ?>
The JSON output looks like this:
[{"id":"22","title":"ASDC 1234 5434","start":"Mon Jul 15 2013 08:00:00 GMT-0400 (Est (heure d\u2019\u00e9t\u00e9))","end":"Mon Jul 15 2013 08:30:00 GMT-0400 (Est (heure d\u2019\u00e9t\u00e9))"},{"id":"23","title":"ASDC 1234 5434","start":"Mon Jul 15 2013 09:00:00 GMT-0400 (Est (heure d\u2019\u00e9t\u00e9))","end":"Mon Jul 15 2013 09:30:00 GMT-0400 (Est (heure d\u2019\u00e9t\u00e9))"}]
I'm totally clueless. Please help.
Thanks