Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/452.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 在FullCalendar中传递动态数据时出错_Javascript_Jquery_Json_Fullcalendar - Fatal编程技术网

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

Javascript 在FullCalendar中传递动态数据时出错,javascript,jquery,json,fullcalendar,Javascript,Jquery,Json,Fullcalendar,我正在使用。我有以下装订 $('#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 n

我正在使用。我有以下装订

$('#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分配给变量并将该变量传递给calendar event时,出现了错误:

404找不到

这里,“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
});

我无法找出这个问题。请建议

我已使用eventSources选项更新了您的代码。试试这个

    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
    eventSources: [{
         events: calendarData
    }]
});

要查看示例,我已使用eventSources选项更新了您的代码。试试这个

    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
    eventSources: [{
         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  );

尝试动态添加事件

  $('#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  );

谢谢你的支持。但我犯了真正的错误

我正在构建我的阵列

calendarData.push({"title": bookingInformations[i].Subject, "start": new Date(bookingInformations[i].StartDateTime).toLocaleString(), "end": new Date(bookingInformations[i].EndDateTime).toLocaleString() });
我刚刚更改了阵列的构建,如下所示

calendarData.push({title: bookingInformations[i].Subject, start: new Date(bookingInformations[i].StartDateTime).toLocaleString(), end: new Date(bookingInformations[i].EndDateTime).toLocaleString()});

它解决了问题。

感谢您的支持。但我犯了真正的错误

我正在构建我的阵列

calendarData.push({"title": bookingInformations[i].Subject, "start": new Date(bookingInformations[i].StartDateTime).toLocaleString(), "end": new Date(bookingInformations[i].EndDateTime).toLocaleString() });
我刚刚更改了阵列的构建,如下所示

calendarData.push({title: bookingInformations[i].Subject, start: new Date(bookingInformations[i].StartDateTime).toLocaleString(), end: new Date(bookingInformations[i].EndDateTime).toLocaleString()});
它解决了这个问题