gpt4 book ai didi

javascript - Fullcalendar 通过 ajax 传递事件数据产生错误

转载 作者:行者123 更新时间:2023-12-03 06:24:00 24 4
gpt4 key购买 nike

我正在尝试通过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');
},

根据选定的时间添加事件工作正常。但我收到以下错误: enter image description here

如果我点击该错误,它会将我带到 moment.js 的以下几行:

function locale_calendar__calendar (key, mom, now) {
var output = this._calendar[key];
return isFunction(output) ? output.call(mom, now) : output;
}

如果我删除ajax部分代码,就没有错误了!但当然,我需要将事件保存到数据库中。知道吗,我做错了什么?

最佳答案

我通过将 start 和 end 转换为 JSON 数据来解决这个问题。目前如下所示:

     $.ajax({
url: '/event/new',
data: {'title': title, 'start': start.toJSON(), 'end':end.toJSON()},
type: "POST",
success: function (json) {
alert('Added Successfully');
}
});

关于javascript - Fullcalendar 通过 ajax 传递事件数据产生错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38732861/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com