FullCalendar json feed error
I am trying to fill my FullCalendar with events using json. But I get an error when trying to load such events. Since I am new to all of this I was trying to load just a single event and I am not even getting the info from a database for now.
$('#calendar').fullCalendar({
defaultView: 'agendaWeek',
theme:true,
allDaySlot: false,
allDayText: false,
minTime: 7,
maxTime: 19,
events: {
url: 'JornadasDeportivas.php',
type: 'POST',
data: {
opcion: 'eventos',
},
error: function() {
alert('Error al cargar los eventos');
}
}
});
My php code is just calling this method
function json(){
echo '
[
{
"title" : "event1",
"allDay" : false,
"start" : "2011-09-09 12:30:00",
"开发者_运维知识库end" : "2011-09-09 15:30:00"
}
]
';
}
and the output is
[ { "title" : "event1", "allDay" : false, "start" : "2011-09-09 12:30:00", "end" : "2011-09-09 15:30:00" } ]
and I always get the error alert. I don't know what I'm doing wrong.Pleeeeaseee help!!! :( Thanks in advance!
as it was said there should be no comma after " opcion: 'eventos' ", last objects attribute (and that also goes for fields in array) should not be followed comma. Most of browsers dont really care about it (for me Chrome/FF are just ignoring it), but IE (at least version 7 I use for some checks) shows an error.
Another problem you can be facing is that your headers are not set correctly. For proper json reading some browser require response with strict "application/json" header, but for IE7 (dont have 8+ so cant say for those for sure) you need to return "text/plain".
There also could be some problem with timeFormat you use, at least in documentation in timeFormat section they show an event time in "2010-01-01T14:30:00" format, so try putting "T" instead of space.
In your case, I would build an event object as normaly php array, set proper header and display it with json_encode function.
I'm not sure but is it the comma after opcion: 'eventos',
精彩评论