2010-10-18 61 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