function getHTTPRequest()
{
var xhr = false ;
if (window.XMLHttpRequest)
xhr = new XMLHttpRequest(); //Browsers except IE
else if (window.ActiveXObject)
{
try
{
xhr = new ActiveXObject("Msxm12.XMLHTTP");//The latest version of ActiveX object
}
catch(e)
{
try
{
xhr = new ActiveXObject("Microsoft.XMLHTTP");
}
catch(e)
{
xhr = false;
}
}
}
}
The following is an application example:
//Complete GET request
var request = getHTTPRequest();
if(request)
{
request.onreadystatechange = dosomething;
request.open("GET"," file.doc",true);
request.send(null);
}