I'me嘗試使用此eventCalendar在Django:http://jquery-week-calendar.googlecode.com/svn/trunk/jquery.weekcalendar/full_demo/weekcalendar_full_demo.html格式的數據阿賈克斯
我想編寫AJAX代碼自己,但在另一方面I'me jQuery的阿賈克斯一個新手,我想發送事件數據包括開始時間,結束時間等,以顯示他們在日曆上:
$('#calendar').weekCalendar({
data: function(callback){
$.getJSON("{% url DrHub.views.getEvents %}",
{
},
function(result) {
callback(result);
}
);
}
});
這個日曆得到這種格式的數據:
return {
events : [
{
"id":1,
"start": new Date(year, month, day, 12),
"end": new Date(year, month, day, 13, 30),
"title":"Lunch with Mike"
},
{
"id":2,
"start": new Date(year, month, day, 14),
"end": new Date(year, month, day, 14, 45),
"title":"Dev Meeting"
},
...
]
};
我如何格式化從DAT獲取的數據在getEvents
查看?
非常感謝@Secator,你的回答非常好,當我要使用數據庫來填寫這個字典時,我得到這個錯誤,「全局名稱」輸出沒有被定義「,我不知道如何定義輸出的循環!我知道我的問題是可笑的,但我不知道我應該尋找什麼來解決這個問題! – 2012-02-26 16:41:58
當我把這之前for循環:輸出= {},它會導致另一個錯誤:「例外類型:KeyError在/醫生/ shahsavand /訪問/ getEvents/ 異常值:'事件'」! – 2012-02-26 17:16:23
嘗試:'output = {「events」:[]}' – 2012-02-26 17:56:53