function getHTTPRequest()
{
var xhr = false;
if (window.XMLHttpRequest)
xhr = new XMLHttpRequest(); //IE除外的浏览器
else if (window.ActiveXObject)
{
try
{
xhr = new ActiveXObject("Msxm12.XMLHTTP");//最新版的ActiveX对象
}
catch(e)
{
try
{
xhr = new ActiveXObject("Microsoft.XMLHTTP");
}
catch(e)
{
xhr = false;
}
}
}
}
接下来是一个应用的实例:
//完整的GET请求
var request = getHTTPRequest();
if(request)
{
request.onreadystatechange = dosomething;
request.open("GET","file.doc",true);
request.send(null);
}
Statement:The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn