2010-09-23 74 views
2

我有一個從cfc返回JSON信息的頁面。該JSON是結構的數組,看起來像這樣:無法從JSON訂閱源在FullCalendar上呈現事件

[ 
    { 
    "allday": true, 
    "title": "event1", 
    "userid": 1, 
    "end": "", 
    "classname": "", 
    "editable": true, 
    "start": "2010-09-01", 
    "id": 1, 
    "url": "" 
    }, 
    { 
    "allday": true, 
    "title": "event2", 
    "userid": 1, 
    "end": "", 
    "classname": "", 
    "editable": true, 
    "start": "2010-09-10", 
    "id": 2, 
    "url": "" 
    } 
] 

當我使用:

$(document).ready(function() { 
    //Create JQuery connection to obj 
    $('#event').hide(); 
    //Make event bubble draggable 
    $('#event').draggable(); 

    $('#evBubbleClose').click(cleanEventBubble); 
    // page is now ready, initialize the calendar... 
    $('#calendar').fullCalendar({ 
     // put your options and callbacks here 
     dayClick: function(date, allDay, jsEvent, view) { 
      createEvent(date, allDay, jsEvent, view, this); 
     }, 
     events: 'http://xxxxx/cfc/FullCalendarEvents.cfc?method=getEvents', 
     theme: true, 
     header: { 
      left: 'prev,next today', 
      center: 'title', 
      right: 'month,agendaWeek,agendaDay' 
     }, 
     editable: true 
    }); 
}); 

該事件不渲染。不過,如果我在這裏複製並粘貼JSON數組中的JSON數組,它將顯示事件。我做錯了事件不會從Feed中呈現?

+0

您是否將您的默認視圖設置爲月視圖?也許你的日曆沒有範圍內的日期,你餵它。只是猜測,因爲代碼似乎對我來說是正確的。 – Francisco 2010-09-23 17:12:35

+0

是否在同一臺服務器上使用JSON?事件:'cfc/FullCalendarEvents.cfc?method = getEvents', – orolo 2010-09-24 20:12:07

回答

1

如果您爲您的活動URL指定FQDN,那麼它與呼叫頁面的FQDN是否相同?如果jQuery用於在不同的域,子域或協議上調用AJAX函數(如從https調用http),則必須使用JSONP包裝器。

詳情about Same Origin PolicyjQuery annd JSON

+0

這實際上是一個愚蠢的人爲錯誤。 ColdFusion正在返回JSON內容的額外垃圾,我必須禁用它。它正在工作 – kevin 2010-09-27 16:23:19