从myfeeds.php(服务器端)返回什么

时间:2012-02-01 14:03:22

标签: jquery jquery-plugins coldfusion fullcalendar coldfusion-9

我从服务器端页面返回以下字符串(getEvents.cfm)。我在ColdFusion工作。

[
{
    title: 'Event1',
    start: '2012-02-02',
    end: '2012-02-02',
    allDay: 'no'
},
{
    title: 'Event2',
    start: '2012-02-03',
    end: '2012-02-03',
    allDay: 'no'
}
]

但我在页面加载时遇到错误'在获取事件时出错!'

以下是我用于获取事件的代码:

eventSources: [

            // your event source
            {
                url: '../getevents.cfm',
                type: 'POST',
                data: {
                    custom_param1: 'something',
                    custom_param2: 'somethingelse'
                },
                error: function() {
                    alert('there was an error while fetching events!');
                },
                color: 'yellow',   // a non-ajax option
                textColor: 'black' // a non-ajax option
            }

            // any other sources...

]

2 个答案:

答案 0 :(得分:2)

首先allDay应该是真/假不是不是/是。其次,返回字符串应如下所示:

 [{
    "title": 'Event2',
    "start": '2012-02-03',
    "end": '2012-02-03',
    "allDay": 'false'
}]

答案 1 :(得分:0)

$.getJSON('path_to_your_json_file',function(data){
   $.each(data,function(index,entry){
      //assuming we already have a <div> created and get the id
         //show the JSON data
      $('#div_id_created_earlier').append('
         'Title: ' + entry.title + '<br \/>' + 
         'Start: ' + entry.start + '<br \/>' +
         'End: ' + entry.end + '<br \/>' +
         'All day: ' + entry.allDay + '<br \/><br \/>' +
      ');
   });
});