Image

AJAX - Request Object - Request Object

Request Object

	 
function getRequestObject()
{
	if (window.XMLHttpRequest)
       {                                      
    		return(new XMLHttpRequest());
	} else if (window.ActiveXObject)
	{ 
		return(new ActiveXObject("Microsoft.XMLHTTP"));
	} else {
		return(null); 
      }
}
		
	

Special things that are used in defining these object.

  • . XMLHttpRequest()= version for firefox,netscape 5+,opera,safari,mozila chrome, internet explorer 7,and IE 8.
  • ActiveXObject = version for internet explorer 5.5 and 6
  • return(null); = Fails on older and nonstandard browsers. You don’t want to do “throw new Error(...)” here because this is for very old browsers, and Error came only in JavaScript 1.5