2013-04-22 43 views
1

我有簡單的flex應用程序,它讀取XML文件並在dataGrid中顯示。當我更改XML文件時遇到問題,因此Chrome在刷新後不刷新此XML數據,甚至不重新啓動Chrome。我認爲XML數據會留在Chrome緩存中?
如何自動刷新此數據?在Firefox functionier正確的..
我的Flex代碼:
Flex - 更新後XML文件在Chrome中顯示舊數據

<?xml version="1.0" encoding="utf-8"?> 
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" 
       xmlns:s="library://ns.adobe.com/flex/spark" 
       xmlns:mx="library://ns.adobe.com/flex/mx" 
       creationComplete="aktualityService.send()"> 
    <fx:Script> 
     <![CDATA[ 
      import mx.collections.ArrayCollection; 
      import mx.controls.Alert; 
      import mx.rpc.events.FaultEvent; 
      import mx.rpc.events.ResultEvent; 


      [Bindable] 
      private var xmlData:ArrayCollection; 

      protected function aktualityService_resultHandler(event:ResultEvent):void 
      { 
       xmlData = new ArrayCollection(); 

       for each (var aktualita:Object in event.result.aktuality.aktualita) 
       { 
        xmlData.addItem(aktualita); 
       } 
      } 

      protected function aktualityService_faultHandler(event:FaultEvent):void 
      { 
       Alert.show("ERROR read xml: " + event.fault.faultString);    
      } 

     ]]> 
    </fx:Script> 

    <fx:Declarations> 
     <s:HTTPService id="aktualityService" 
         url="data/aktuality.xml" 
         result="aktualityService_resultHandler(event)" 
         fault="aktualityService_faultHandler(event)" 
         method="GET"/> 

    </fx:Declarations> 


    <s:DataGrid id="dataGridId" 
       y="100" x="0" dataProvider="{xmlData}" /> 
</s:Application> 

然後我在Flash Builder導出發佈版本,並複製到我的服務器。

回答

3

以防止緩存使用一個隨機數,如文件路徑後:

<s:HTTPService id="aktualityService" 
       url="data/aktuality.xml?{UIDUtil.createUID()}" 
       result="aktualityService_resultHandler(event)" 
       fault="aktualityService_faultHandler(event)" 
       method="GET"/> 
+0

super..thats it..thank你了.. – 2013-04-22 17:36:29

+0

感謝標記爲正確答案;我很高興我能幫助你! – 2013-04-22 20:53:59

相關問題