What is the best method for creating an XMLHttpRequest object?
It should work in all capable browsers.
function CreateXmlHttpObj() {
try {
XmlHttpObj = new ActiveXObject("Msxml2.XMLHTTP");
}
catch (e) {
try {
XmlHttpObj = new ActiveXObject("Microsoft.XMLHTTP");
}
catch (oc) {
XmlHttpObj = null;
}
}
// if unable to create using IE specific code then try creating for Mozilla (FireFox)
if (!XmlHttpObj && typeof XMLHttpRequest != "undefined") {
XmlHttpObj = new XMLHttpRequest();
}
}