简体   繁体   English

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

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

I want to get the function for the specific event: 我想获取特定事件的功能:

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

and i have a code for the full calendar event i want to do it specifically for the prev or next event and i want to get the start and end date from that function please help me friends and currently by the coding i given bellow its returning the current date 我有一个完整的日历事件的代码,我想专门针对上一个或下一个事件,并且我想从该函数中获取开始和结束日期,请帮助我的朋友们,目前通过编码,我给了它下面的返回信息当前的日期

Jquery part: 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 part: 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>

you can use viewDisplay callback 您可以使用viewDisplay回调

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

you can get start and end date like this 您可以像这样获得开始日期和结束日期

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

}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM