O'Reilly logo

jQuery and JavaScript Phrasebook by Brad Dayley

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Geting an XMLHttpRequest Object

var xmlhttp; if (window.XMLHttpRequest){ //newer Browsers   xmlhttp=new XMLHttpRequest(); } else {// Older IE6, IE5   xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); }

Newer browsers provide the XMLHttpRequest object directly as window.XMLHtpRequest. Older IE browsers do not provide an XMLHttpRequest object directly. Instead, they use an ActiveXObject("Microsoft.XHMLHTTP") object. If you want your AJAX code to support the older browsers, you need to add an alternative way of getting the access to an XMLHttpRequest by building the IE version if window.XMLHttpRequest is not available.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required