I want to make a javascript function to create a Request Object in Ajax. I want it to work for modern browsers only, and the question is: do I really need to difference between two possibilities?
function createRequestObject(){
var reqObj;
var browser = navigator.appName;
if(browser == "Microsoft Internet Explorer"){
reqObj = new ActiveXObject("Microsoft.XMLHTTP");
}else{
reqObj = new XMLHttpRequest();
}
return reqObj;
}
If I use directly the XMLHttpRequest(), would it work in major browsers? Why or why not?