Chapter 9. Talking with the Server

In this lesson you’ll learn how to use the properties and methods of the XMLHTTPRequest object to allow the object to send requests to and receive data from the server.

Sending the Server Request

Lesson 8, “The XMLHTPPRequest Object,” discussed at some length the JavaScript XMLHTTPRequest object and how an instance of it may be created in various different browsers.

Now that we have our XMLHTTPRequest object, let’s consider how to create and send server requests, and what messages we might expect to receive back from the server.

We’re going to jump right in and first write some code using what you learned in Lesson 8 to create an XMLHTTPRequest object called myRequest. We’ll then write a JavaScript function called ...

Get SAMS Teach Yourself Ajax in 10 Minutes 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.