How to create an XMLHttpRequest Object in IE5 and IE6
-
xmlhttp=new XMLHttpRequest();
-
xmlhttp=new XMLHttpRequest("Microsoft.XMLHTTP");
-
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
-
IE5 and IE6 do not support XMLHttpRequest
In Internet Explorer 5 and 6, the XMLHttpRequest object was implemented as an ActiveX control rather than a native JavaScript object. The correct syntax is xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"). Modern browsers use new XMLHttpRequest(), but this doesn't work in IE5/IE6.
In legacy Internet Explorer 5 and 6, XMLHttpRequest was not a native global object — it was only available (and had to be instantiated) via new ActiveXObject("Microsoft.XMLHTTP"), an ActiveX COM component. Native new XMLHttpRequest() support only arrived in IE7+. The other options are invalid: passing a string argument to new XMLHttpRequest() isn't valid syntax in any browser, and the claim that IE5/6 don't support XMLHttpRequest at all is false — they support it, just through the ActiveX mechanism rather than a native constructor. This is classic early-2000s cross-browser AJAX boilerplate (if (window.XMLHttpRequest) ... else ... ActiveXObject).