Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jsf-2/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 向fullcalendar请求添加自定义参数_Javascript_Jquery_Fullcalendar - Fatal编程技术网

Javascript 向fullcalendar请求添加自定义参数

Javascript 向fullcalendar请求添加自定义参数,javascript,jquery,fullcalendar,Javascript,Jquery,Fullcalendar,我想将名为foo的参数添加到fullcalendar在检索事件数据时提交的请求中。根据这一点,可通过以下方式实现: var getFoo() = function() { // implementation omitted }; $('#calendar').fullCalendar({ loading: function(isLoading) { // CAN I SOMEHOW UPDATE foo FROM HERE? }, events

我想将名为
foo
的参数添加到fullcalendar在检索事件数据时提交的请求中。根据这一点,可通过以下方式实现:

var getFoo() = function() {
    // implementation omitted
};

$('#calendar').fullCalendar({

    loading: function(isLoading) {
        // CAN I SOMEHOW UPDATE foo FROM HERE?
    },
    events: {
        url: '/myfeed.php',
        type: 'POST',
        data: {
            foo: getFoo()
        }       
    }

});
我希望每次请求日历事件数据时都计算
foo
参数的值,但fullcalendar似乎只在第一次加载时调用
getFoo()
,然后在每次后续请求中重新使用该值

我曾尝试使用此函数加载数据之前立即触发的
加载
事件,但我不知道如何在此函数中更新
foo
参数

更新 我遵循了以下建议,并使其与此一起工作:

        $('#calendar').fullCalendar({
            events: function(start, end, callback) {
                $.ajax({
                    url: 'getCalendarEvents',
                    dataType: 'json',
                    data: {

                        start: Math.round(start.getTime() / 1000),
                        end: Math.round(end.getTime() / 1000),
                        foo: getFoo()
                    },
                    success: function(doc) {
                        var events = eval(doc);
                        callback(events);
                    }
                });
            },
        });
也许您可以使用创建自己的ajax请求

var getFoo() = function() {
    // implementation omitted
};

$('#calendar').fullCalendar({
    events: function(start, end, callback) {
        var myFoo = getFoo();
        $.ajax({
            url: 'myxmlfeed.php',
            dataType: 'xml',
            data: {
                // our hypothetical feed requires UNIX timestamps
                start: Math.round(start.getTime() / 1000),
                end: Math.round(end.getTime() / 1000),
                foo: myFoo
            },
            success: function(doc) {
                var events = [];
                $(doc).find('event').each(function() {
                    events.push({
                        title: $(this).attr('title'),
                        start: $(this).attr('start') // will be parsed
                    });
                });
                callback(events);
            }
        });
    }
});

尝试将lazyFetching设置为false。我猜您会遇到这个问题,因为fullCalendar试图将您从不必要的ajax请求中解救出来