3 Replies Latest reply on Apr 29, 2007 6:36 PM by darrylfrith

    http request

      I have a flex app that I'm using with apollo. I retrieve data for a column chart through an http request. I am sending the request with a button click. But What I do not understand is why it only works once. After that when you press the button the data does not update. not until I close the app and open again. Can someone please tell me what I am doing wrong.

      Here is my code :

      <?xml version="1.0" encoding="utf-8"?>
      <mx:Application xmlns:mx=" http://www.adobe.com/2006/mxml" layout="absolute" height="280" width="350" xmlns="*" creationComplete="initApp();">

      padding: 0px;

      /* additional style declarations... */
      import mx.rpc.events.ResultEvent;
      [Bindable] private var data_result:Object;
      private function show_data(evt:ResultEvent):void {
      data_result = evt.result;

      private function initApp():void

      this.bgBox.addEventListener(MouseEvent.MOUSE_DOWN, onMouseDown);


      <mx:HTTPService id="get_pageloads" url=" http://www.mydomain.com/flex_data.php" useProxy="false" method="POST" result="show_data(event)">
      <mx:request xmlns="">

      <mx:SeriesInterpolate id="mySeriesEffect" duration="1000" minimumElementDuration="200" elementOffset="0"/>
      <mx:Panel id="bgBox" x="0" y="0" width="100%" height="100%" layout="absolute" alpha="1.0" backgroundAlpha="1.0" title="{data_result.alltime.date}" fontWeight="bold" fontSize="14">
      <mx:ColumnChart showDataTips="true" left="2" right="3" id = "columnchart1" dataProvider="{data_result.chartData.columnData}" height="208" y="7" >
      <mx:CategoryAxis id="x_axis" dataProvider="{data_result.chartData.columnData}" categoryField="day"/>
      <mx:ColumnSeries itemRenderer="@Embed('glass.png')" yField="pageLoads" showDataEffect="{mySeriesEffect}"/>
      <mx:HBox bottom = "4" y ="4" x ="5">
      <mx:RadioButton groupName="stocks" label="Days"
      selected="true" click="x_axis.dataProvider=data_result.chartData.columnData; columnchart1.dataProvider=data_result.chartData.columnData; "/>
      <mx:RadioButton groupName="stocks" label="Months"
      click="x_axis.dataProvider=data_result.chartData2.columnData; columnchart1.dataProvider=data_result.chartData2.columnData; "/>
      <mx:Button x="217" y="32" label="Refresh" click="get_pageloads.send();"/>

      private function onMouseDown(evt:MouseEvent):void



        • 1. Re: http request
          chris.huston.t10 Level 3
          It looks like your data is being cached. There are a couple of options to prevent caching. Try adding this code to your flex_data.php page:

          header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
          header('Cache-Control: no-store, no-cache, must-revalidate');
          header('Cache-Control: post-check=0, pre-check=0', FALSE);
          header('Pragma: no-cache');

          If this doesn't work, then try appending the current time to your HTTPService call so it will always appear unique and thus not use a chached value.

          • 2. Re: http request
            JAF Site Design
            would you mind posting the site so I can try to figure it out? (can't see if I fixed it without having data to call)
            • 3. Re: http request
              darrylfrith Level 1
              It was a caching problem. I added the current date to the http request and it works now. Thanks so much for the help. That was driving me crazy.