AJAX - The Complete Reference

(avery) #1

540 Part III: Advanced Topics


As this process may take a while, we start a timer to look every half-second and see if
our files are available for offline usage yet:

/* check every 500 ms to see if it is all saved or not */
var timerId = window.setInterval(function() {
if (store.currentVersion)
{
window.clearInterval(timerId);
document.getElementById("responseOutput").innerHTML ="The documents
are now available offline.";
}
else if (store.updateStatus == 3)
document.getElementById("responseOutput").innerHTML =
"Error: " + store.lastErrorMessage;
}, 500);

Now that the files are safely stored, if the user were to go offline and attempt to use the
files of interest, they could do so. If they have not captured the files, they would of course
see the expected error message. These scenarios are shown in Figure 10-12.
If for some reason we want to remove the stored data, it is easily done like so:

localServer.removeManagedStore("lockbox");

FIGURE 10-12 Offl ine access: scenarios with Gears
Free download pdf