Uncaught TypeError: callback is not a function FullCalendar
Uncaught TypeError: callback is not a function FullCalendar
我在尝试将活动放入日历时遇到问题,错误显示:
document.addEventListener("DOMContentLoaded", function () {
var calendarEl = document.getElementById("calendar");
var calendar = new FullCalendar.Calendar(calendarEl, {
initialView: "dayGridMonth",
events: function (start, end, timezone, callback) {
jQuery.ajax({
url: "/getAllCitas",
type: "GET",
success: function (doc) {
var events = [];
doc.forEach(function (evt) {
events.push({
title: evt.paciente,
start: evt.date,
end: evt.date,
});
});
console.log(events);
callback(events);
},
});
},
});
calendar.render();
});
错误
Uncaught TypeError: callback is not a function
at Object.success (citas.js:179)
at c (jquery.min.js:2)
at Object.fireWith [as resolveWith] (jquery.min.js:2)
at l (jquery.min.js:2)
at XMLHttpRequest.<anonymous> (jquery.min.js:2)
活动结果。该文档 json 包含更多信息,我只需要事件中的信息。
0: {title: undefined, start: "2021-03-18", end: "2021-03-18"}
1: {title: undefined, start: "2021-04-02", end: "2021-04-02"}
2: {title: undefined, start: "2021-04-02", end: "2021-04-02"}
3: {title: undefined, start: "2021-04-06", end: "2021-04-06"}
4: {title: undefined, start: "2021-04-05", end: "2021-04-05"}
5: {title: "603fd0e423f0d241ecfdd337", start: "2021-04-06", end: "2021-04-06"}
6: {title: "Carlos", start: "2021-04-08", end: "2021-04-08"}
我需要你的帮助,谢谢
我得到了解决方案,你说的回调来自旧版本。现在它是 successCallback,我改变了它,现在它可以工作了,这是新代码
document.addEventListener("DOMContentLoaded", function () {
var calendarEl = document.getElementById("calendar");
var calendar = new FullCalendar.Calendar(calendarEl, {
initialView: "dayGridMonth",
events: function (fetchInfo, successCallback, failureCallback) {
jQuery.ajax({
url: "/getAllCitas",
type: "GET",
success: function (res) {
var events = [];
res.forEach(function (evt) {
events.push({
title: evt.paciente,
start: evt.date,
end: evt.date,
});
});
successCallback(events);
},
});
},
});
calendar.render();
});
谢谢
我在尝试将活动放入日历时遇到问题,错误显示:
document.addEventListener("DOMContentLoaded", function () {
var calendarEl = document.getElementById("calendar");
var calendar = new FullCalendar.Calendar(calendarEl, {
initialView: "dayGridMonth",
events: function (start, end, timezone, callback) {
jQuery.ajax({
url: "/getAllCitas",
type: "GET",
success: function (doc) {
var events = [];
doc.forEach(function (evt) {
events.push({
title: evt.paciente,
start: evt.date,
end: evt.date,
});
});
console.log(events);
callback(events);
},
});
},
});
calendar.render();
});
错误
Uncaught TypeError: callback is not a function
at Object.success (citas.js:179)
at c (jquery.min.js:2)
at Object.fireWith [as resolveWith] (jquery.min.js:2)
at l (jquery.min.js:2)
at XMLHttpRequest.<anonymous> (jquery.min.js:2)
活动结果。该文档 json 包含更多信息,我只需要事件中的信息。
0: {title: undefined, start: "2021-03-18", end: "2021-03-18"}
1: {title: undefined, start: "2021-04-02", end: "2021-04-02"}
2: {title: undefined, start: "2021-04-02", end: "2021-04-02"}
3: {title: undefined, start: "2021-04-06", end: "2021-04-06"}
4: {title: undefined, start: "2021-04-05", end: "2021-04-05"}
5: {title: "603fd0e423f0d241ecfdd337", start: "2021-04-06", end: "2021-04-06"}
6: {title: "Carlos", start: "2021-04-08", end: "2021-04-08"}
我需要你的帮助,谢谢
我得到了解决方案,你说的回调来自旧版本。现在它是 successCallback,我改变了它,现在它可以工作了,这是新代码
document.addEventListener("DOMContentLoaded", function () {
var calendarEl = document.getElementById("calendar");
var calendar = new FullCalendar.Calendar(calendarEl, {
initialView: "dayGridMonth",
events: function (fetchInfo, successCallback, failureCallback) {
jQuery.ajax({
url: "/getAllCitas",
type: "GET",
success: function (res) {
var events = [];
res.forEach(function (evt) {
events.push({
title: evt.paciente,
start: evt.date,
end: evt.date,
});
});
successCallback(events);
},
});
},
});
calendar.render();
});
谢谢