开发者

FullCalendar not Working in CakePHP 1.2.5 with jQuery 1.4.1

I am trying to fetch the events data through a URL which will return JSON data. The same code is working with jQuery 1.3.2 but not with jQue开发者_开发问答ry 1.4.1

I am getting this error in FireBug console


a is undefined

for (var i=0; i

fullcalendar.js (line 369)


I am getting the JSON data as I can check it in response header of FireBug jQuery 1.4.1 imposes strict JSON parsing I am not sure whether it is the issue.

I have kept the FullCalendar example in apache webroot. If I use "/fullcalendar/examples/json-events.php" for events instead of my CakePHP AJAX url "/myCake/calendars/get_events" it is working for jQuery 1.4.1. But if I inlude the same code in "/fullcalendar/examples/json-events.php" in my CakePHP get_events.ctp file which generates the same JSON, it is giving the same error with jQuery 1.4.1

If anybody has encountered the same problem and found a solution or work around, it will be very helpfull if you share your experience.


it definitely sounds like jquery 1.4.1 is enforcing strict json rules (http://yehudakatz.com/2010/01/15/jquery-1-4-and-malformed-json/) and that is why the error is occuring. that line in fullcalendar.js is where it parses the feed, so makes sense. i'd look at the json in firebug and see if there are double quotes around every string. if not, this is definitely your problem.

im not that familiar with cakephp, but if you want a quick hack with events as a function, i'd do the following or something like it...

$('#calendar').fullCalendar({
    events: function(start, end, callback) {
        $.getJSON('yourfeed.php', { start:start, end:end }, function(data) {
             callback(eval("(" + data + ")"));
        });
    }
});


My problem was that jquery 1.4.1+ doesn't accept single quotes in JSON, so that was an easy fix but I guess you're not in a position where you can change the generated JSON?

Arshaws example work very well (thank you arshaw for a great plugin btw :)). Or you can use jquery-json plugin to eval the json response in a secure way.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜