AJAX - The Complete Reference

(avery) #1

PART III


Chapter 10: Web Services and Beyond 535


A convenience method of getAll() is also provided that returns an array of all items in
client persistence.
To remove a value from storage, use the remove() method, passing it the key and the
persistence object:

AjaxTCR.storage.remove("way to a mans heart",persistObj);
// removed value

A similar convenience method, clear(), is provided to remove all items from storage.
The full syntax of the AjaxTCR storage mechanism is detailed in Table 10-4 and can also be
found in Appendix C.
You can try the persistence system using the AjaxTCR library in your browser with our
simple explorer program (http://ajaxref.com/ch10/persistenceexplorer.html).

Danger: Offl ine Ahead!

Just because we have saved some data into our client-side persistent storage, it doesn’t
necessarily allow us go offline. For example, let’s use our Hello World style example. If we
go offline in our browser:

and then attempt to make the call, we may raise an exception, depending on the browser.
For example, in Firefox 2 we do not seem to have problems as long as we have previously
requested the page. However, regardless of a previous request or not, in other browsers like
Internet Explorer, you will most likely throw an error when you issue the XHR request in
offline mode.
Free download pdf