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.

Get jQuery and JavaScript Phrasebook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.