Home > Adobe Flex/Air > HTTPService result remains previous loaded data

HTTPService result remains previous loaded data

I have a form with a Datagrid and an add new button (Original from http://learn.adobe.com/wiki/display/Flex/CRUD+-+Dynamic). When this form is launched, it’ll load all data and display on grid. After first call, although i tried to add new records to database, the display content of Datagrid is still the same as before.

This problem took me a lot of time before i figured out how to solve. It seems that the HTTP response had been cached by IE because the request URL remains the same each time the form is loaded.

So the key is how to change the request content when a request is launched? The answer is that we can use timestamp as a request parameter. This’s because the value of timestamp keep changing each time we have a request, so it’ll always be different.

<mx:HTTPService
   id="employeesService"
   url="http://localhost/flex/php/1/employees.php?{new Date().toDateString() + new Date().toTimeString()}"
   resultFormat="e4x"
   useProxy="false" />
Advertisements
Categories: Adobe Flex/Air Tags:
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: