Ajax

In Chapter 3, we added an Ajax request to the News application, transforming the application from a static data reader to a dynamic application serving up new stories from multiple feeds in the background. There is a huge difference in user experience when your application can let the user know that something new exists and present it to her immediately.

You aren’t required to use the Prototype functions. You can use the XMLHttpRequest object directly, and you will be required to if your data protocols are SOAP-based or if they are anything other than simple XML, JSON, or text-based web services. There are many references for XMLHttpRequest if you’d like to explore this more directly. Any fundamental JavaScript reference will give you an overview, but for more in-depth information, look for Ajax-specific references such as Anthony Holdener’s Ajax: The Definitive Guide (O’Reilly). For a more basic introduction, you can review the tutorial at https://developer.mozilla.org/en/XMLHttpRequest, which, while focused on Firefox, is nonetheless a good introduction to XMLHttpRequest.

The Ajax class functions, which are a basic feature of the Prototype JavaScript library, are included with webOS because they encapsulate the lifecycle of an XMLHttpRequest object and handlers into a few simple functions. The next few pages will explore these functions to show you how Prototype can help you integrate dynamic data into your application.

Note

Palm webOS applications are run from file:// URLs and ...

Get Palm webOS now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.