0
votes

I am working to integrate MySQL events in Fullcalendar.

I've read many guide/post but i can't import events from a json script. Now, if I paste the JSON result of "myfeed.php" in fullcalendar, my calendar works and it include all events. If I link fullcalendar to myfeed.php, the calendar is empty. I've tried, also, to link my calendar to fullcalendar's "get-events.php" (that should work with myfeed.php), but the calendar is always empty. :/

this is my fullcalendar:

$(document).ready(function() {

          $('#calendar').fullCalendar({
              header: {
                  left: 'prev,next today',
                  center: 'title',
                  right: 'month,agendaWeek,agendaDay'
              },
              editable: true,
              eventLimit: true, // allow "more" link when too many events
              events: {
                  url: 'fullcalendar/php/get-events.php',
                  //url: 'fullcalendar/myfeed.php',
                  error: function() {
                      $('#script-warning').show();
                  }
              },
              loading: function(bool) {
                  $('#loading').toggle(bool);
              }
          });

      });

this is the result of myfeed.php:

[{“id”:”1″,”title”:”allenamentosimone”,”allDay”:”false”,”start”:”1423036800″,”end”:”1423044000″,”url”:”pippo”},
{“id”:”2″,”title”:”allenamentodue”,”allDay”:”true”,”start”:”1423310400″,”end”:”1423335600″,”url”:”pluto”}]

and myfeed.php is visible on pastebin (for the site jsonformatter the result is a valid json, but the file isn't a valid json).

Any suggestion?


UPDATE:

I've changed the event url in: url: 'fullcalendar/myfeed.php'

Also, i've changed the date format of my json in YYYY-MM-DD HH:II:SS and now i can see my events on fullcalendar. However I see all events in all day mode :/

This is the new json returnment:

[
{"id":"1","title":"allenamentosimone","allDay":"false","start":"2015-02-04 09:00:00","end":"2015-02-04 11:00:00","url":"pippo"},
{"id":"2","title":"allenamentodue","allDay":"true","start":"2015-02-07 13:00:00","end":"2015-02-07 20:00:00","url":"pluto"}
]

UPDATE N.2:

If i don't write anything in allDay section, my fullcalendar works perfectly! This is the last json returnment:

[
{"id":"1","title":"allenamentosimone","allDay":"","start":"2015-02-04 09:00:00","end":"2015-02-04 11:00:00","url":"pippo"},
{"id":"2","title":"allenamentodue","allDay":"true","start":"2015-02-07 13:00:00","end":"2015-02-07 20:00:00","url":"pluto"}
]
1
i think it's because allDay is not string, it's boolean. don't use quotes around true/false.rasso

1 Answers

0
votes

events should be single url to feed from database.

So replace events like this:

events: 'fullcalendar/php/get-events.php',

Check in browser inspector if it tries to reach DB file. In Chrome it opens with Ctrl+Shift+i and navigate to Network tab. Database URL is relative from browser url where you use it.

For example, if you have page testfullcalnedar.io/mycalendar And lets say your php is located on testfullcalnedar.io/mycalendar/fullcalendar/php/get-events.php'.

Then in script events feed URL would be fullcalendar/php/get-events.php OR /mycalendar/fullcalendar/php/get-events.php

Explanation - if you begin feed URL with / it will start search it from root of your domain else it will search relative to location where script is. In my example case script runs under testfullcalnedar.io/mycalendar