user281867
user281867

Reputation: 587

Fullcalendar not display return data

I have a coldfusion cfc that i call to query events between the start and end date. Here is my script:

$(document).ready(function() {

var calendar = $('#calendar').fullCalendar({
  events: function(start, end, callback) {
$.ajax({
    type: "GET",
    url: 'cfc/forecast.cfc?method=GetForecast&returnformat=plain',
    data: {
         startDate: start.getDate(),
         startMonth: start.getMonth(),
         startYear: start.getFullYear(),
                 endDate: end.getDate(),
         endMonth: end.getMonth(),
         endYear: end.getFullYear()
    },
    success: function(data) {
        callback(data);
    }
});
 } 
 });
});

In firebug the return data looks like this:

[
  {"ID": 16, "start": "2010-01-04 00:00:00.0", "end": "", "title": "AM 2 Hours: 2 - 2"},
  {"ID": 16, "start": "2010-01-04 00:00:00.0", "end": "", "title": "AM 2 Hours: 2 - 2"},
  {"ID": 16, "start": "2010-01-04 00:00:00.0", "end": "", "title": "PM 2 Hours: 2 - 2"},
  {"ID": 16, "start": "2010-01-04 00:00:00.0", "end": "", "title": "PM 2 Hours: 2 - 2"}
] 

I'm new to Javascript, jQuery and FullCalendar so please forgive me. I know I'm missing something but can't figure out what it is. Any suggestions is much appreciated!

thanks,

Upvotes: 0

Views: 965

Answers (2)

user281867
user281867

Reputation: 587

I found the solution here http://www.jamesnetherton.com/blog/2008/05/04/Converting-Unix-timestamp-values-in-ColdFusion/. I needed to convert the start and end time in order to use in my sql query.

Upvotes: 0

Jeff Treuting
Jeff Treuting

Reputation: 13510

There are a few things that it might be.

1) All the ids are the same. If you don't specifically use them you can not include them and fullcalendar will auto assign an ID.

2) It might be case sensitive. The JSON I get back has it as id instead of ID.

3) Are these supposed to be all day events? If so use the "allDay": true property in the JSON. Since there is no end date I'm assuming it is an all day thing.

Give those a try. But also ...

If you have control over the ColdFusion script that you are calling, you can change it to just receive a start and end parameters that are timestamps, and return the proper JSON. Then you can just pass in the URL as a string to the events: property and it takes care of everything for you.

$('#calendar').fullCalendar({
  events: 'cfc/forecast.cfc?method=GetForecast&returnformat=plain'
});

Upvotes: 2

Related Questions