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)
This topic is archived.