jQuery in Action

218
CHAPTER 8
Talk to the server with Ajax
It can be successfully argued that no one technology has transformed the land-
scape of the web more in recent years than the adoption of Ajax. The ability to
make asynchronous requests back to the server without the need to reload pages
has enabled a whole new set of user interaction paradigms and made Rich Inter-
net Applications possible.
Ajax is a less recent addition to the web toolbox than many people may realize.
In 1998, Microsoft introduced the ability to perform asynchronous requests
under script control (discounting the use of
<iframe>
elements for such activity)
as an ActiveX control to enable the creation of Outlook Web Access (
OWA
).
Although
OWA
was a moderate success, few people seemed to take notice of the
underlying technology.
A few years passed, and a handful of events launched Ajax into the collective
consciousness of the web development community. The non-Microsoft browsers
implemented a standardized version of the technology as the
XMLH
ttpRequest
(
XHR
) object; Google began using
XHR
; and, in 2005, Jesse James Garrett of
Adaptive Path coined the term Ajax (for Asynchronous JavaScript and
XML
).
As if they were only waiting for the technology to be given a catchy name, the
web development masses suddenly took note of Ajax in a big way, and it has become
one of the primary tools by which we can enable Rich Internet Applications.
In this chapter, we'll take a brief tour of Ajax (if you're already an Ajax guru,
you might want to skip ahead to section 8.2) and then look at how jQuery makes
using Ajax a snap.
Let's start off with a refresher on what Ajax technology is all about.
8.1 Brushing up on Ajax
Although we'll take a quick look at Ajax in this section, please note that it's not
intended as a complete Ajax tutorial or an Ajax primer. If you're completely unfa-
miliar with Ajax (or worse, still think that we're talking about a dishwashing liquid
or a mythological Greek hero), we encourage you to familiarize yourself with the
technology through resources that are geared towards teaching you all about Ajax;
the Manning books Ajax in Action and Ajax in Practice are both excellent examples.
Some people may argue that the term Ajax applies to any means to make
server requests without the need to refresh the user-facing page (such as by sub-
mitting a request to a hidden
<iframe>
element), but most people associate the
term with the use of
XHR
or the Microsoft
XMLHTTP
ActiveX control.
Let's take a look at how those objects are used to generate requests to the
server, beginning with creating one.


Другие страницы

 
Cкачать книги бесплатно без регистрации в электронном виде (pdf, chm, txt).Вы можете читать книги онлайн на нашем сайте литературного портала книг.Большая подборка учебников, пособий, интересных книг.Электронные книги на английском языке скачать бесплатно без смс.