Coding With Fun
Home Docker Django Node.js Articles FAQ

XMLHttpRequest object

May 27, 2021 XML

Table of contents

XMLHttpRequest object

XMLHttpRequest object

The XMLHttpRequest object is used to exchange data with the server in the background.

The XMLHttpRequest object is a developer's dream because you can:

  • Update the page without reloading it
  • Request data from the server after the page has been loaded
  • Receive data from the server after the page has been loaded
  • Send data to the server in the background

To learn more about XMLHttpRequest objects, learn from our XML DOM tutorial.

XMLHttpRequest instance

When you type a character in the input field below, an XMLHttpRequest is sent to the server - a recommendation to return the name (files from the server):

Type a letter in the input box:

The first letter


Create an XMLHttpRequest object

All modern browsers (IE7 Plus, Firefox, Chrome, Safari, and Opera) have built-in XMLHttpRequest objects.

Create the syntax of the XMLHttpRequest object:

xmlhttp=new XMLHttpRequest();

ActiveX objects were used in older versions of Internet Explorer (IE5 and IE6):

xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");

In the next chapter, we'll use the XMLHttpRequest object to get the XML information back from the server.