Skip to Content
Learning JavaScript
book

Learning JavaScript

by Shelley Powers
October 2006
Beginner to intermediate
352 pages
9h 33m
English
O'Reilly Media, Inc.
Content preview from Learning JavaScript

How Ajax Works

Ajax is not as complicated as it may seem at first. A request needs to be sent to the server, a service invoked, and data returned. However, instead of submitting a form and loading a new page with the response, Ajax handles all of this activity within the context of the same page.

A special object, either Microsoft’s ActiveXObject or the more general XMLHttpRequest, manages the asynchronous communication between the server and the client. Asynchronous means that the request is sent, but the client doesn’t have to stop, hold, and wait for the process to finish; there is no twirly icon to signal working while you twiddle your thumbs. Instead, the client provides a function to be called when the state of the request changes. In this function, this state is checked; then, based on its value, as well as the status of the request, the data returned from the service is processed and usually output to the page in some form.

To the web-page reader, all of this activity looks as if the processing is happening within the page, rather than through client/server interaction. The only indicator that server access is happening is if this information is specifically provided.

Now that we’ve had the 10,000-foot view, let’s look first at an Ajax application, and then go through the individual pieces in the rest of the chapter.

Tip

Ajax does require a server-side component. I’m using PHP for this book because PHP is probably one of the most common scripting languages used today. Also, in ...

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.

Read now

Unlock full access

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

Learning JavaScript, 2nd Edition

Learning JavaScript, 2nd Edition

Shelley Powers

Publisher Resources

ISBN: 0596527462Catalog PageErrata