What is XMLHttpRequest object in XML

This article describe about XMLHttpRequest object in XML
  • 2432

The XMLHttpRequest Object

XMLHttpRequest Object is used to update only some portion of the web page , not the whole page. In this technique whole page does not reload only some part of page relode.

The XMLHttpRequest Object

The use of XMLHttpRequest  object is transfer data between the client and server. Which are not visible by the user

XMLHttpRequest object fulfill the developer dream , because

  •  Without the reloading the whole page update the web page
  • After the page has loaded request data from the server
  • After the page has loaded receive data from the server
  • Send data from a server it is a backend process.

Create an XMLHttpRequest Object

The mostly modern browser like (IE7+, Firefox, Chrome, Safari, and Opera) have a already buit-in XMLHttpRequest object.

These are the following syntax that create XMLHttpRequest object.

xmlhttp=new XMLHttpRequest();


The older version of Internet Explorer (IE5 and IE6) uses an ActiveX Object.


For example


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


For handling all modern browser as well as IE5 and IE6, check if the browser supports the XMLHttpRequest object. If it does this, then create an XMLHttpRequest object, if does not support then create an ActiveXObject. 


if (window.XMLHttpRequest)
  {// code for IE7+, Firefox, Chrome, Opera, Safari
  xmlhttpobj=new XMLHttpRequest();
  {// code for IE6, IE5
  xmlhttpobj=new ActiveXObject("Microsoft.XMLHTTP");

Send a Request To a Server

When request send to the server use the method open() and send() of XMLHttpRequest object.



Method Description
open(method,url,async) It is specifies the type of request, that the URL, and if the request should be handled asynchronously or not.
method: It is specified the type of request: weather GET or POST
url: It is specified the location of the file on the server
async: true (asynchronous) or false (synchronous)
send(string) This method sends the request  to the server.
string: It is Only used for POST requests

Further Readings

You may also want to read these related articles :

Ask Your Question 

 Got a programming related question? You may want to post your question here

Programming Answers here

© 2020 DotNetHeaven. All rights reserved.