2010-10-18 59 views
0

我正在使用jQuery fullcalendar和Grails。我之前使用的是事件(作为json提要),当用户单击prev/next或更改视图时,每次都会调用json提要URL。因为我也需要检查用户会话,所以我将事件(作为json提要)更改为事件(如函数),如下所示。问题是它第一次工作,但下一次,ajax请求不会被发送到服务器,IE从缓存中显示。如果我清除浏览器缓存,则它会从服务器再次获取它。jQuery fullcalendar:事件(作为json提要)和事件(作为函数)问题在IE

所以问题是,IE缓存事件对象。我可以知道我做错了什么吗?奇怪的是,这可以在Firefox和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(){ 
        });  
        } 
      }); 
     } 

回答

5

尝试缓存属性设置为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(){ 
        });  
        } 
      }); 
     } 
+0

谢谢非常!解决了它!完善! :) – 2010-10-18 16:09:31

0

只是后一个随机数你的要求作为一个GET参数。

像这样:URL = yoururl?unique=45686541654 - >(唯一编号)

这样每个请求是唯一一个

你可以检查我的回答后here一个类似的问题/解决方案

+0

也谢谢你的帮助。 :) – 2010-10-18 16:09:58