Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do get jquery fullcalendar to pass additional parameters to my json feed script

My code is as follows

jQuery('#calendar').fullCalendar({
    weekMode: 'liquid',
    events: themeforce.events,
    eventRender: function (event, element) {
        element.find('span.fc-event-title').html(element.find('span.fc-event-title').text());           
    }
});

where themeforce.events is a variable containing an encoded url of the json feed a php file - all works well.

I tried replacing events: themeforce.events, with

events: {
    url: themeforce.events,
    type: 'POST',
    data: {
        custom_param1: 'something',
        custom_param2: 'somethingelse'
    },

However now the calendar fails to load.

What can I do?

like image 395
lukehm Avatar asked Sep 17 '25 08:09

lukehm


1 Answers

I wanted the start and end times for a post ajax request and it took me a bit of time to work it out.

This might help you:

events: function(start, end, timezone, callback) {
$.ajax({
    url: url,
    type: 'POST',
    dataType: 'json',
    data: {
        start: start.format(),
        end: end.format(),
        custom_param1: 'value 1',
        custom_param2: 'value 2',
    },
    error: function () {
        alert('there was an error while fetching events!');
    },
    success: function(doc) {
        var events = [];

        $.each(doc,function (index, e) {
            events.push(e);
        });

        callback(events);
    }
});
}
like image 95
Robert Harrison Avatar answered Sep 20 '25 07:09

Robert Harrison