I am trying to create xml http request object, I can't find where I am going wrong, when I try to alert the object it prints false
var xmlHttpObject = createXmlHttpRequestObject();
alert(xmlHttpObject); // return object is false is my problem
function createXmlHttpRequestObject() {
var xmlHttpObject;
//mozilla browser
if (window.ActiveXobject) {
try {
xmlHttpObject = new ActiveXobject("Microsoft.XMLHTTP");
alert(xmlHttpObject);
} catch (e) {
xmlHttpObject = false;
}
} else {
try {
xmlHttpObject = XMLHttpRequest();
alert('test'); //it is not coming in to the block itself
} catch (e) {
xmlHttpObject = false;
}
}
if (xmlHttpObject) {
alert("object created");
} else {
alert("object not created");
return xmlHttpObject;
}
}