views:

53

answers:

2

Hi,

I am using jQuery fullcalendar with Grails. I was using events (as a json feed) earlier and when the user clicks prev/next or changes views the json feed URL is called every time.

Since I need to check the user session also, I changed from events (as a json feed) to events (as function) as shown below. The problem is first time it works, but next time onwards the ajax request is not being send to the server and IE is showing from the cache. If I clear the browser cache, then it gets it again from the server.

So the problem is, IE is caching the event objects. Can I know what I am doing wrong? Strangely this works fines in Firefox and Chrome.

//events: calendarEventsURL            
        events: function(start, end, callback) {
            $.ajax({
                url: calendarEventsURL,
                data: {
                    start: Math.round(start.getTime() / 1000),
                    end: Math.round(end.getTime() / 1000)
                },
                success: function(msg) {
                    if(msg == "no-session"){                    
                        $("#wait").html(invalidSessionMsg).fadeIn('fast',function(){
                            $("#wait").fadeOut(2000,function(){
                                window.location= "/" + $("#appName").val() + "/";
                            });    
                        });                    
                    } else {
                        var events = [];
                        for(var c = 0; c < msg.length; c++){
                            events.push({
                                id: msg[c].id,                                
                                title: msg[c].title,
                                allDay: false,
                                start: msg[c].start,
                                end: msg[c].end
                            });
                        }
                        callback(events);
                  } 
                } , error: function(){                                  
                      $("#wait").html(errorMsg).fadeIn('fast',function(){
                    });    
                  }
            });
        }
+1  A: 

Try setting cache property to false:

//events: calendarEventsURL            
        events: function(start, end, callback) {
            $.ajax({
                cache: false,
                url: calendarEventsURL,
                data: {
                    start: Math.round(start.getTime() / 1000),
                    end: Math.round(end.getTime() / 1000)
                },
                success: function(msg) {
                    if(msg == "no-session"){                    
                        $("#wait").html(invalidSessionMsg).fadeIn('fast',function(){
                            $("#wait").fadeOut(2000,function(){
                                window.location= "/" + $("#appName").val() + "/";
                            });    
                        });                    
                    } else {
                        var events = [];
                        for(var c = 0; c < msg.length; c++){
                            events.push({
                                id: msg[c].id,                                
                                title: msg[c].title,
                                allDay: false,
                                start: msg[c].start,
                                end: msg[c].end
                            });
                        }
                        callback(events);
                  } 
                } , error: function(){                                  
                      $("#wait").html(errorMsg).fadeIn('fast',function(){
                    });    
                  }
            });
        }
Diego
Thank you very much! That solves it!! Perfect! :)
Jay Chandran
A: 

just post a random number with your request as a Get parameter.

like so: url = yoururl?unique=45686541654 ->(unique number)

this way every request is a unique one

you can check my answer post here for a similar problem/solution

Nealv
thank you for your help also. :)
Jay Chandran