Skip to Main Content
Adding Ajax
book

Adding Ajax

by Shelley Powers
June 2007
Intermediate to advanced content levelIntermediate to advanced
400 pages
9h 52m
English
O'Reilly Media, Inc.
Content preview from Adding Ajax

Chapter 2. The Ajax Bits

What sets Ajax apart from JavaScript is its use of in-page requests for external data and its ability to return the results without reloading the page. The request can be as simple as loading a new image or stylesheet, or as complex as loading an entire XML document that updates many parts of the page. The data from the web service can be integrated into the page through dynamic scripting—creating a scripting block that consists of a callback function and the returned data. Typically, though, the request is made to a web service through a key object, XMLHttpRequest.

The concept of an object that manages web service requests from script within a web page originated several years ago with Internet Explorer 5.0. The original object was an ActiveX object, and Microsoft continued to support that approach with IE 6.x. Now, though, like the other browsers, Microsoft supports the XMLHttpRequest object.

The XMLHttpRequest object is one of the simpler browser objects to work with: a web service request is created, the request is sent, and a callback function is invoked to process the response. Rather than all of this activity spread across many pages, as is the case with traditional web applications, it's all accomplished within the same web page, without any page reloads.

Tip

There are so many acronyms in this business. I use XMLHttpRequest throughout much of the book, but I, and other developers, also sometimes just say XHR to save both time and typing.

The Web Application ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Ajax: The Definitive Guide

Ajax: The Definitive Guide

Anthony T. Holdener III
Ajax Design Patterns

Ajax Design Patterns

Michael Mahemoff
Web Development with JavaScript and Ajax Illuminated

Web Development with JavaScript and Ajax Illuminated

Richard Allen, Kai Qian, Lixin Tao, Xiang Fu

Publisher Resources

ISBN: 9780596529369Supplemental ContentErrata Page