我正在使用FullCalendar制定计划,我遇到了一些障碍.我正在尝试使用事件回调函数来创建一个新事件,并将新事件的信息发送到我的php脚本,然后将该信息存储到服务器.但每当我尝试从其中一个回调中调用$ .ajax或$ .post时(我已尝试过,如果来自其中一些)我得到了这个:
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
Run Code Online (Sandbox Code Playgroud)
但是因为我使用的是Moment.min.js,所以很难读出问题的来源,所以我用Moment.js替换了Moment.min.js,当错误再次出现时,我能够读到问题是:
months : function (m) {
return this._months[m.month()];
},
Run Code Online (Sandbox Code Playgroud)
根据我收集的内容,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
}, …Run Code Online (Sandbox Code Playgroud)