Work off-line with Ajax

Michael Schwarz on Monday, July 3, 2006

In Internet Explorer (and all other common web browsers) you have an menu item File -> Work off-line. What does this do with you web application? Of course, it is working offline, no communication possible to the web server. When connected with a dial-up connection it can happen that this is done automatically if you disconnect from your internet service provider.

What does this mean to web developers?

Yes, you have to be sure your Ajax framework or requests are working correct with this mode. If your web browser is set to Work off-line you should display a message box that the current requests could not be processed due a connection problem, try again later.

With Ajax.NET Professional [1] you will get an error message in your callbacks:

<script type="text/javascript"> function callback(res) { if(res.error != null) { alert(res.error.Message); return; } // display return value... } </script>

Because Firefox and other web browsers currently not returning a correct error code [2] for all scenarios you have to deal with the common error handling: try again or cancel request.

Try to visit your Ajax web application, wait until everything is loaded correctly, set the mode to Work off-line and try to invoke Ajax requests.