The XHR object was originally created by Microsoft as an ActiveX object back in 2000.
Mozilla went on to create a native implementation of XHR in 2002; since then, Safari and
Opera have added support for it.
Ajax in itself is fairly straightforward, but handling all the contingencies might not be
obvious. JavaScript libraries provide a framework for handling successful calls and problem
calls (timeouts, for example). Chapter 5 will discuss Ajax in more detail.
Strings and Templating
When you work with Ajax-based web applications, you frequently take data that has been
received from the server and place it on the page somehow. The quickest way to do it is to
receive a full HTML snippet from the server and just plunk it on the page. However, that
process isn??™t very practical. You end up using a lot of bandwidth just to send a little bit of data.
Templating solves this problem by enabling data received from the server to be quickly
merged with a template and then embedded in the page.
Additionally, web programming constantly uses strings, and having ways to filter, capitalize,
or camel case strings can be extremely handy.
Here??™s an example using Prototype to combine a data set with a template to create a list of
links:
CHAPTER 4 n LIBRARIES 83