如何将当前日期范围从 Fullcalendar 传递到 JSON 函数

How do I pass current date range from Fullcalendar to the JSON function

我使用 fullcalendar eventsources 函数,从数据库中获取事件数据:

eventSources: getSources()

getSources 在哪里

getSources(){
 var mysources = {
   mysourceone:{
                url: YOUR URL TO GET JSON,
                type: 'POST', 
                data:{
                    st:'2016-08-19',et:'2016-08-24'
                 },     
                 cache: false,
                 color: '#C1272D',
                 textColor: 'white'
                 }
              }
  return [mysources.mysourceone];
}

我的问题是,如何将此函数中的固定日期替换为全日历中当前选定的日期范围?

                data:{
                    st:'2016-08-19',et:'2016-08-24'
                 }, 

FullCalendar 应该 pass the start and end dates automatically,因此只需将它们排除在您的调用之外,在 FullCalendar 检查事件的页面上,您可以访问 $_GET['start']$_GET['end'] 并查询您的数据库基于这些日期。您还可以转到浏览器检查器并查看网络选项卡,同时在日历上切换月份、周或视图,并查看它发出的呼叫。您还可以附加自己的变量,例如用户 ID、时区等。