Reputation: 361
I retrive events from database using events url, but events are not display in fullcalnder??
my Js codes is
$('#inspectionCalendar').fullCalendar({
header: {
left: 'next today',
center: 'title',
right: 'month,basicWeek,basicDay'
},
editable: false,
eventLimit: true, // allow "more" link when too many events
events: '<?php echo base_url(); ?>inspections/inspections_record',
});
My controller action is :
function inspections_record() {
echo "[
{
title: 'All Day Event',
start: '2015-08-01'
},
{
title: 'Long Event',
start: '2015-02-07'
},
{
id: 999,
title: 'Repeating Event',
start: '2015-08-09T16:00:00'
},
{
id: 999,
title: 'Repeating Event',
start: '2015-08-16T16:00:00'
},
{
title: 'Conference',
start: '2015-08-26'
},
{
title: 'Meeting',
start: '2015-08-25T10:30:00',
},
{
title: 'Lunch',
start: '2015-08-25T12:00:00'
},
{
title: 'Meeting',
start: '2015-08-25T14:30:00'
},
{
title: 'Happy Hour',
start: '2015-08-12T17:30:00'
},
{
title: 'Dinner',
start: '2015-08-12T20:00:00'
},
{
title: 'Birthday Party',
start: '2015-08-13T07:00:00'
},
{
title: 'Click for Google',
url: 'http://google.com/',
start: '2015-08-28'
}
],";
}
The console of my browser shows the response, but the events are not showing in the calender?
Please help me.
Thanks
Upvotes: 0
Views: 165
Reputation: 1045
I think you should remove the comma at the end of the JSON
you are echoing, right after the ]
. You also have to surround the names and values in your json with double quotes instead of single quotes. That will make inspections_record()
look like:
function inspections_record() {
echo '[
{
"title": "All Day Event",
"start": "2015-08-01"
},
{
"title": "Long Event",
"start": "2015-02-07"
},
{
"id": 999,
"title": "Repeating Event",
"start": "2015-08-09T16:00:00"
}
etc...
]';
}
Conclusion: The events JSON
that you are feeding to the calendar is not valid JSON
. This will cause the calendar to not show your events.
Upvotes: 1