Ose*_*eer 2 ajax jquery json fullcalendar
我知道有一些关于如何在 FullCalendar 中使用多个提要源的示例,即: Stackoverflow 帖子
然而,它们都没有展示如何使用多个 feed 源以及附加的 ajax 信息,例如类型、数据等。
我正在尝试使用多个源,但无法使其工作。这是我的代码:
eventSources: [
'json-schedule.php',
'json-events.php'
],
type: 'POST',
data: {
// custom_param1: 'something',
},
error: function() {
alert('there was an error while fetching events!');
},
success: function() {
},
Run Code Online (Sandbox Code Playgroud)
多个数据源中的类型、数据、错误和成功部分位于何处?我发现的例子都没有表明这一点。
试试这个方法:
$('#calendar').fullCalendar({
...
eventSources: [
// your JSON event source
{
url: '/myfeed.php', // use the `url` property
color: 'yellow', // an option!
textColor: 'black' // an option!
},
// your ajax event source
{
events: function(start, end, callback) {
$.ajax({
url: 'myxmlfeed.php',
dataType: 'xml',
data: {
// our hypothetical feed requires UNIX timestamps
start: Math.round(start.getTime() / 1000),
end: Math.round(end.getTime() / 1000)
},
success: function(doc) {
var events = [];
$(doc).find('event').each(function() {
events.push({
title: $(this).attr('title'),
start: $(this).attr('start') // will be parsed
});
}
});
}
}
],
...
});
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
16801 次 |
| 最近记录: |