gpt4 book ai didi

javascript - 在 FullCalendar 中传递动态数据时出错

转载 作者:行者123 更新时间:2023-12-01 03:53:32 25 4
gpt4 key购买 nike

我正在使用FullCalendar 。我有以下绑定(bind)

$('#calendar').fullCalendar({
header: {
left: 'prev,next today',
center: 'title',
right: 'month,agendaWeek,agendaDay'
},

defaultDate: '2017-03-23',
navLinks: true, // can click day/week names to navigate views
editable: true,
eventLimit: true, // allow "more" link when too many events
events: [{ "title": "General Meeting", "start": "3/23/2017, 10:00:00 AM", "end": "3/23/2017, 11:00:00 AM" }, { "title": "Client Meeting", "start": "3/23/2017, 12:00:00 PM", "end": "3/23/2017, 1:00:00 PM" }]
});

以上代码完美运行。

但是当我尝试将 json 分配给变量并将该变量传递给日历事件时,我收到错误:

https://site-url/MyData 404 NOT FOUND

这里,“MyData”是我的 json 数据。它附加了 URL 并抛出上述错误。

我正在使用的示例代码

var calendarData = [{ "title": "General Meeting", "start": "3/23/2017, 10:00:00 AM", "end": "3/23/2017, 11:00:00 AM" }, { "title": "Client Meeting", "start": "3/23/2017, 12:00:00 PM", "end": "3/23/2017, 1:00:00 PM" }];
$('#calendar').fullCalendar({
header: {
left: 'prev,next today',
center: 'title',
right: 'month,agendaWeek,agendaDay'
},

defaultDate: '2017-03-23',
navLinks: true, // can click day/week names to navigate views
editable: true,
eventLimit: true, // allow "more" link when too many events
events: calendarData
});

我无法找出问题所在。请推荐

最佳答案

尝试动态添加事件

  $('#calendar').fullCalendar({
header: {
left: 'prev,next today',
center: 'title',
right: 'month,agendaWeek,agendaDay'
},

defaultDate: '2017-03-23',
navLinks: true, // can click day/week names to navigate views
editable: true,
eventLimit: true, // allow "more" link when too many events
});

var calendarData = [{ "title": "General Meeting", "start": "3/23/2017, 10:00:00 AM", "end": "3/23/2017, 11:00:00 AM" }, { "title": "Client Meeting", "start": "3/23/2017, 12:00:00 PM", "end": "3/23/2017, 1:00:00 PM" }];
$("#calendar").fullCalendar( 'addEventSource', calendarData );

关于javascript - 在 FullCalendar 中传递动态数据时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42976075/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com