Creating and Sending Requests

The key to implementing the Ajax-style communication described above is the JavaScript request object, which is built into Internet Explorer 6.0 and later, Firefox 0.8 and later, Opera 7.54 and later, and Safari 1.2.2 and later. Your JavaScript can use this request object to query a webserver for information, store the returned information, and update the page when the server has provided the information.

There are four steps involved in using JavaScript to make an Ajax request:

  1. Creating a request object

  2. Telling the request object where to send the request

  3. Telling the object what to do when the request is answered

  4. Telling the object to make the request

Creating a Request Object

The first step in making an Ajax request is ...

Get The Book of JavaScript, 2nd Edition now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.