AJAX XMLHttpRequest

XMLHttpRequest object is used to exchange data with a Web service.

XMLHttpRequest object allows you to update parts of your web page without reloading or refreshing your page.

XMLHttpRequest object is key to using AJAX.

Syntax to create a XMLHttpRequest object in a modern web browser:

myVariable=new XMLHttpRequest();

Syntax to create a XMLHttpRequest object in an old web browser:

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

Therefore, the syntax to work in any browser

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