Native XMLHttpRequest in IE 7

Published on Tuesday, January 24th, 2006

The IE team has made a very wise decision to natively support XMLHttpRequest in IE 7. XMLHTTPRequest is the foundation of any AJAX usage, and I for one applaud the move to make it available without the demand for using ActiveXObject.

Using object detection, one can easily make your code backwards compatible as well:


var oXMLHttp;
if(typeof XMLHttpRequest != "undefined"){
	/* Code for:
		IE 7
		Firefox, Mozilla etc
		Safari
		Opera
	*/
	oXMLHttp = new XMLHttpRequest();
}
else if(typeof window.ActiveXObject != "undefined"){
	/*
		Code for:
			IE 5
			IE 6
	*/
	oXMLHttp = new ActiveXObject("Msxml2.XMLHTTP");
}

Share your thoughts:

HTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> . If you want to display code examples, please remember to write &lt; for < and &gt; for >.

Comment preview

Top results