i have a problem when i'm trying to put the events on the calendar, an error show:
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();
});
Error
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)
event result. The doc is a json that have more infomation i only need the information like it is in the event.
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"}
I need your help, thanks
I got the solution, the callback like you said was from an old version. Now its successCallback, i change it and now it works, this is the new code
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();
});
Thanks
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With