:: Forum >>

refresh only if data has been changed

hi everyone!

I´m using the grid with a dyn. XML which is loaded from a servlet.
Every 1-2 seconds i´m refreshing the grid, because the xml is extended from time to time (but not always, sometimes there are for 10-20seconds no changes)

My problem is now, i don´t want the list to be refreshed always. Only if the xml data has been changed. How can i implement for example a simple data size check in the refresh function of the grid ?

Please with code example ;-)

br René
Saturday, January 21, 2006
René, the best solution to this is to modify your server side code to return a proper response status code.

Usually, what you get from the server is status 200 (OK), unless there is an error, in which case you get 500, or if you don't have enough privilages to access the resource you get 401, or if the resource is not found you get 404. There are many other codes, but in any case, you can check the status by calling status() method on the request object.

You should modify your servlet to return 304 (Not Modified) is there is no change in data. Then you can simply do something like this:

var request = .. //create new request object
//set up request object
//send request
//wait for the request to return
if( request.status() == 200 )
// refresh data
else if( request.status() == 304 )
// don't do anything
else if( request.status() == 500 )
// display error

I'd recommend looking through these documents:

1. http://developer.apple.com/internet/webcontent/xmlhttpreq.html -- for the specifics of the xmlHttpRequest
2. http://www.faqs.org/rfcs/rfc2616.html (section 10.3.5) -- for 304 status code definition (that document also has explainations for other codes)
Saturday, January 21, 2006

This topic is archived.

Back to support forum

Forum search