我正在尝试通过ajax发送事件数据以将它们保存到数据库。以下是我的代码:
select: function(start, end) {
var title = prompt('Event Title:');
if (title) {
calendar.fullCalendar('renderEvent',
{
title: title,
start: start,
end: end
},
true // make the event "stick"
);
}
$.ajax({
url: '/event/new',
data: {'title': title, 'start': start, 'end':end},
type: "POST",
success: function (json) {
alert('Added Successfully');
}
});
calendar.fullCalendar('unselect');
},
如果我点击该错误,我需要将moment.js改为以下几行:
function locale_calendar__calendar (key, mom, now) {
var output = this._calendar[key];
return isFunction(output) ? output.call(mom, now) : output;
}
如果删除代码的ajax部分,则没有错误!但是当然,我需要将事件保存到数据库。 任何想法,我在做什么错?
答案 0 :(得分:1)
我通过将start和end转换为JSON数据解决了这个问题。目前如下所示:
$.ajax({
url: '/event/new',
data: {'title': title, 'start': start.toJSON(), 'end':end.toJSON()},
type: "POST",
success: function (json) {
alert('Added Successfully');
}
});