【发布时间】:2014-11-09 17:20:48
【问题描述】:
我正在使用 FullCalendar 制定时间表,但遇到了一些障碍。我正在尝试使用事件回调函数来创建一个新事件,并将新事件的信息发送到我的 php 脚本,然后将信息存储到服务器。但是,每当我尝试从其中一个回调中调用 $.ajax 或 $.post 时(我已经尝试过其中一些回调中的 if),我都会得到:
Uncaught TypeError: Cannot read property 'month' of undefined moment.js:684
extend.monthsShort moment.js:684
e jquery.min.js:4
Bc jquery.min.js:4
Bc jquery.min.js:4
Bc jquery.min.js:4
n.param jquery.min.js:4
n.extend.ajax jquery.min.js:4
$.fullCalendar.select advisorSchedule.js:141
Q fullcalendar.min.js:6
s fullcalendar.min.js:7
a fullcalendar.min.js:7
(anonymous function) fullcalendar.min.js:6
d jquery.min.js:3
n.event.dispatch jquery.min.js:3
r.handle
但是因为我使用的是 Moment.min.js,所以很难看出问题出在哪里,所以我用 Moment.js 替换了 Moment.min.js,当错误再次出现时,我能够阅读问题出在哪里:
months : function (m) {
return this._months[m.month()];
},
根据我收集的信息,在执行此函数时,m 是未定义的。 这是我用来将新事件数据发布到 php 脚本的代码:
select:function(start, end, jsEvent, view){
CURRENT_SELECTION_START = start;
CURRENT_SELECTION_END = end;
console.log(CURRENT_SELECTION_START + '-' + CURRENT_SELECTION_END);
$.ajax({
url:'../AJAX/save_event.php',
type: 'POST',
data: {
Start_Time: start,
Event_Title: prompt('Title'),
End_Time: end
},
});
},
【问题讨论】:
标签: ajax callback fullcalendar typeerror momentjs