gpt4 book ai didi

javascript - 我可以将日程安排作为 ajax 放在 fullcalendar 中吗?

转载 作者:行者123 更新时间:2023-11-30 06:21:21 25 4
gpt4 key购买 nike

我想在 Laravel 中添加全日历计划功能。该方法按预期工作,但我不明白如何处理响应数据。

$('#calendar').fullCalendar({
header: {
left : 'today, prev,next',
center: 'title',
right : '',
},
locale:'ko',
height:'parent',
events : function(start, end, timezone, callback){
var month = $('#calendar').fullCalendar('getDate').format('YYYY-MM');
var url = '{{route('reservation.get_schedule',[request()->id])}}';
alert(url)
$.ajax({
type : 'get',
data : {'date' : month},
url : url,
datatype : 'json',
success : function(data){
console.log(data); // How do I use the data
}
});
}
});

最佳答案

documentation对于事件即函数说:

[The function]... will also be given callback, a function that must be called when the custom event function has generated its events. It is the event function’s responsibility to make sure callback is being called with an array of Event Objects.

该页面上还有一个示例,其中使用回调函数将从 AJAX 调用返回的事件数据传递到 fullCalendar。

因此在您的情况下(假设您的事件数据已经采用 fullCalendar 要求的格式并且不需要任何转换)您只需在“成功”回调中添加对此函数的调用:

events : function(start, end, timezone, callback){
var month = $('#calendar').fullCalendar('getDate').format('YYYY-MM');
var url = '{{route('reservation.get_schedule',[request()->id])}}';
alert(url)
$.ajax({
type : 'get',
data : {'date' : month},
url : url,
datatype : 'json',
success : function(data){
console.log(data);
callback(data); //pass the event data to fullCalendar via the provided callback function
}
});
}

关于javascript - 我可以将日程安排作为 ajax 放在 fullcalendar 中吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52850058/

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