You can use the Channel API and open a channel that waits for a message when you get logged out.
However, Channel API calls are pretty expensive, so this could end up being more expensive.
The cheapest way to go would be to return a particular error code if you're logged out, and handle that error code across all your AJAX calls.