简体   繁体   English

fullcalendar.io:jsonfeed不起作用

[英]fullcalendar.io : jsonfeed is not working

I am trying to load JSON data using jsonfeed as displayed blow. 我正在尝试使用显示的打击使用jsonfeed加载JSON数据。

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

I am getting JSON data but it is not getting displayed on Calendar. 我正在获取JSON数据,但未在日历上显示。 Blow is JSON data. 打击是JSON数据。

{
  "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. 当您的JSON文件没有' end '字段时,它将仅通过' allDay '事件传递。 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. 此外,请记住,如果使用的是utils.php文件,则FullCalendar如果与开始字段相同,则会使end字段为空,以减少推送到FullCalendar的数据量。

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. 我注意到FullCalendar喜欢UTF-8格式。 In the myFeed.php, make sure to convert the text before decoding the file: 在myFeed.php中,请确保在解码文件之前先转换文本:

$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: 当您将事件作为json字段调用时:

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

Here is a URL that FullCalendar might visit: 这是FullCalendar可能访问的URL:

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

But, in your json file, there is no field named end . 但是,在您的json文件中,没有名为end的字段。 Try adding it. 尝试添加它。

Also, there are other ways you can find here to get the JSON value from file. 此外,您还可以在这里找到其他方法来从文件中获取JSON值。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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