HTML and CSS Reference
In-Depth Information
Figure 8-5. Chrome showing offline application details
n Note Different browsers have different ways to show details of offline applications. For example, Firefox shows
these details in the Tools Options Advanced Network dialog. Additionally, Firefox informs you that a web
application is requesting offline storage when the application is initially accessed.
Going Online Using Ajax
Although an offline application is disconnected from the server, during the lifetime of the application it
may need to go online and communicate with the server. Suppose you wish to save the current time
displayed in the Clock application in a database. You can do that only if a network connection is available.
A sure way to tell if a network connection is available is to make a request to the server and see if the
request is successful. The jQuery $.ajax() method can be used effectively for this purpose. Listing 8-8
shows how you can use $.ajax() to ping the server periodically.
Listing 8-8. Checking Whether a Network Connection Is Available Using $.ajax()
$(document).ready(function () {
setTimeout(CheckOnline, 5000);
Search WWH ::

Custom Search