简体   繁体   中英

fullcalendar.io : jsonfeed is not working

I am trying to load JSON data using jsonfeed as displayed blow.

$('#calendar').fullCalendar({
    events: '/myfeed.php'
});

I am getting JSON data but it is not getting displayed on Calendar. Blow is JSON data.

{
  "events": [
    {
      "start": "2017-04-25",
      "title": "Event1"
    },
    {
      "start": "2017-04-26",
      "title": "Event2"
    }
  ]
}

Also I am unable to get any nice tutorial on it. It will be much better if tutorial is also provided.

When your JSON file does not have ' end ' field, it would only pass through ' allDay ' events. I have tested this on my site. Also, keep in mind that FullCalendar nulls out end field if it is the same as start field to reduce the amount of data that is pushed to FullCalendar if you are using the utils.php file.

If that does not help, you would also want to check the format of the text. I have noticed that FullCalendar likes UTF-8 format. In the myFeed.php, make sure to convert the text before decoding the file:

$json = mb_convert_encoding($json, 'UTF-8',mb_detect_encoding($json, 'UTF-8, ISO-8859-1', true));
$input_arrays = json_decode($json, true);

Hope this helps.

When you call events as a json field:

$('#calendar').fullCalendar({
    events: '/myfeed.php'
});

Here is a URL that FullCalendar might visit:

/myfeed.php?start=2013-12-01&end=2014-01-12&_=1386054751381

But, in your json file, there is no field named end . Try adding it.

Also, there are other ways you can find here to get the JSON value from file.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM