如何在jquery fullcalendar中通过ajax从php中获取数据,当单击prev r next函数时


How to fetch the data from a php through ajax in the jquery fullcalendar when click prev r next function

我想获得特定事件的函数:

$('#my-prev-button').click(function() {
    $('#calendar').fullCalendar('prev');
});

我有一个完整日历事件的代码,我想专门为上一个或下一个事件做,我想从该功能中获得开始和结束日期,请帮助我的朋友,目前通过我在下面给出的代码返回当前日期

Jquery部分:

 $('#calendar').fullCalendar({
                //                 theme:true,
                    header: {
                        left: 'prev,next today',
                        center: 'title',
                        right: 'month,agendaWeek,agendaDay'
                    },
                    defaultDate:"2014-11-01",
        events: function(start, end, timezone, callback) {
            $.ajax({
                url: 'myxmlfeed.php',
                type:'post',
                dataType: 'html',
                data: {
                    start: start.format(),
                    end: end.format()
                },
                success: function(doc) {
                    var events = [];
                    $(doc).find('event').each(function() {
                        events.push({
                            title: $(this).attr('title'),
                            start: $(this).attr('start'), // will be parsed
                            end: $(this).attr('end')
                        });
                    });

          callback(events);
            }
        });
    }
});

XML部分:

<xml>
<event id="1" title="first entry" url="http://www.google.com" start="2014-12-22" />
<?php 
$start = $_GET['start'];
?>
<event id="2" title="first entry" url="http://www.google.com" start="<?php $start; ?>" />
<event id="3" title="fir entry" url="http://www.google.com" end="<?php $_GET['end']; ?>" /> 
</xml>

您可以使用viewDisplay回调

$('#calendar').fullCalendar({         
    viewDisplay: function(view) {
         callBackfn(view.visStart ,view.visEnd);
   }
});

你可以像这个一样得到开始和结束日期

function callBackfn(startDate,endDate){ 
   var datesArray = getDates(startDate,endDate);
}