The XMLHTTPRequest object in javascript with safari does, on occasion, set the status for the return request as 'undefined'. It seems this is a problem with safari 1.3, and I do believe in 2.0 as well, when trying to retrieve pages from the browser cache using XMLHTTPRequest or AJAX as the kids are calling it these days.
I have been loading static XHTML template files for dynamic rendering as a way to make simple reusable dynamic UI components, and to avoid having to generate HTML within javascript. These templates are static XHTML, and they do indeed become cached. When an attempt to retrieve these cached pages using XMLHTTPRequest within safari 1.3 the status is defined as, well, undefined.
So my code was dumping errors left and louie:
if (req.status != 200) {
alert("http connect error\nstatus: " + req.status);
and the alert looked kinda like:
There was a problem retrieving data from the server status: undefined
It took me forever to figure it out. Finally, I found a post from an apple mailing list archive that solved the problem for me.
"Basically you want to add something like the following before the call to send."
xmlReq.setRequestHeader('If-Modified-Since', 'Wed, 15 Nov 1995 00:00:00 GMT');
This tells the client (safari) to retrieve any document who's modified date is later the Nov 15, 1995 from the server, none of this new fangled cached document stuff...now, if your fetching an XML document from 1994, well you're out of luck my friend.
update: I should of mentioned that this does in fact stink, as the client is forced to retrieve the document over the network when it has a version of the document cached locally.

