CHAPTER 14

image

Ajax

Asynchronous JavaScript and XML, or Ajax, is a methodology for exchanging data with the server in the background, without having to do a full page refresh. This allows elements of a page to be updated based on user events, without disrupting what the user is doing on the page, thereby enabling the development of highly responsive web applications.

Exchanging Data

An Ajax request is made using the XMLHttpRequest object. The first step to making a request is to create an instance of this object.

var myRequest = new XMLHttpRequest();

To handle the server’s response, an event handler is attached to the onload event of this object. ...

Get JavaScript Quick Syntax Reference 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.