我正在使用全日历,我要做的是当用户单击事件时,然后询问用户是否要延长课程时间。如果用户之前取消了课程(在我的数据库中),那么用户可以将课程时间延长15分钟。因此,如果用户可以扩展该类,则可以使用ajax和php将信息发送到mysqlDB。但是,问题是所有信息(正确的是endDate,startDate和canceledCourseDate,以及end(在扩展之前的endDate))都正确地发送到了ajax,但出现错误。
未捕获的TypeError:无法读取未定义的属性'_calendar'
因此,我搜索了一些信息,并添加了.format(“ YYYY-MM_DD HH:mm”),但仍然有问题。
这是js代码
var canceledList = <?php echo $json_array4; ?>; //not newlyBooked canceled Date List
var canceledListNum = canceledList.length;
var extensionList = <?php echo $json_array10; ?>;
var extendedListNum = extensionList.length;
var canceledDate = '';
var extensionStatus = 'going';
if(extendedListNum > 0)
{
canceledDate = extensionList[0]['canceledCourseDate']; //get canceledDate that is alreay in extension
}
else if(canceledListNum > 0)
{
canceledDate = canceledList[0]['canceledCourseDate']; //if there is no course that is in extension, then get new canceledDate that isn't done yet.
extensionStatus = 'new';
}
var id = calEvent.id;
var teacher = calEvent.resourceId;
var extendedDate = moment(calEvent.start.format("YYYY-MM-DD HH:mm"));
var end = moment(calEvent.end.format("YYYY-MM-DD HH:mm"));
var endDate = moment(end).add(15, 'minutes');
console.log(start);
console.log(extendedDate);
console.log(end);
console.log(endDate);
console.log(canceledDate);
var limit = 2;
var userDuration = '<?php echo $userDuration; ?>';
if(userDuration == '60')
{
limit = 4;
}
if(id == '<?php echo $userID; ?>')
{
}
else // extend lesson
{
if(new Date(start) < new Date(today))
{
alert("cannot extend the class");
}
else{
if(canceledDate == '')
{
alert("cannot extend the class");
}else
{
$.ajax({
url:"extend.php",
type:"POST",
data:{userName: '<?php echo $name; ?>' , canceledCourseDate: canceledDate, extendedDate: extendedDate , endDate: endDate ,courseTeacher : teacher, userBranch:'<?php echo $userBranch; ?>', userID: '<?php echo $userID; ?>', duration : '<?php echo $userDuration; ?>', originalEnd : end, extensionStatus: extensionStatus},
success:function(response)
{
console.log(response);
$("#calendar").fullCalendar('refetchEvents');
alert("Successfully extended.");
location.reload();
}
});
}
}
}
}
这是控制台的图像,
答案 0 :(得分:0)
var end = moment(calEvent.end.format("YYYY-MM-DD HH:mm"));
这不起作用。但是,
var endDateForAdd = moment(endDate).format("YYYY-MM-DD HH:mm");
这有效。