What's going on here?

This is an example of using HTTP status codes and a global ajax event handler to communicate information about serverside state (such as session expiration). When "value=valid" is POSTed to the server, it works is returned in the normal fashion. When value isn't "valid", the server sets the status code to a value that indicates the request isn't valid, and the global ajax event handler picks up on this.

In my example, I'm using error code 410, because it seems like it's unlikely to conflict with anything else, or have any side effects, and it's still an "error code" (in the 4xx block). 401 Unauthorized might be an obvious response, but I was concerned that it might trigger wierd browser login prompts, and the spec requires that you also send along other headers if you use 401, so I avoided it.

See here for more on response codes.

Note, Safari is really pick about setting the response code properly. The server has to send a properly formatted response code, and a non-empty body for safari (safari 2 anyways) to work right.