我只是無法弄清楚這段代碼有什麼問題,我有所有依賴加載jquery 1.9.1 jquery UI 1.10.2,fullcalendar.min.js,並且正如下面的示例一樣。Fullcalendar無法發佈有效的JSON
這裏是我的Ajax調用:
$(document).ready(function() {
$('#calendar').fullCalendar({
events: {
type: 'POST',
url: 'mypage.cfc',
data: JSON.stringify({ param_one: "test", param_two: "testing"}),
contentType: "application/json; charset=utf-8",
dataType: "json",
error: function() {
//alert('there was an error while fetching events!');
},
color: 'yellow', // a non-ajax option
textColor: 'black' // a non-ajax option
}
});
});
在ColdFusion的後端頁,也就是期待JSON,我一直得到JSON解析失敗,所以我檢查螢火蟲看到什麼是在POST發送和它不會發送有效的JSON數據。這裏顯示了POST什麼螢火蟲:
0=%7B&1=%22&2=p&3=a&4=r&5=a&6=m&7=_&8=o&9=n&10=e&11=%22&12=%3A&13=%22&14=t&15=e&16=s&17=t&18=%22&19=%2C&20=%22&21=p&22=a&23=r&24=a&25=m&26=_&27=t&28=w&29=o&30=%22&31=%3A&32=%22&33=t&34=e&35=s&36=t&37=i&38=n&39=g&40=%22&41=%7D&start=1361685600&end=1365310800
我也嘗試微調代碼完全放下,看看我是否能縮小問題了,所以我只是累了:
$(document).ready(function() {
$('#calendar').fullCalendar({
events: 'mypage.cfc'
});
});
而且在這種情況下,根本沒有任何東西被髮布。我在參數標籤中看到:
_ 1364228830548
end 1365310800
format json
start 1361685600
我在這裏錯過了什麼?有任何想法嗎?
你爲什麼想要串線?不'data:{param_one:「test」,param_two:「testing」}'工作嗎? – ganeshk 2013-03-25 16:43:43
@ganeshk我試着不先串起來,它也沒有發佈有效的JSON。 W/O stringify帖子看起來像這樣:param_one = test&param_two = testing&start = 1361685600&end = 1365310800 – Amir 2013-03-25 16:53:43
這是正確的,對吧?你的Coldfusion後端不是可以處理的嗎?問題可能是FullCalendar從不以JSON格式發送任何東西 - 儘管如此,它仍然是「期待」JSON結果。 – ganeshk 2013-03-25 16:57:17