javascript一个无懈可击的实例化XMLHttpRequest的方法
时间:2024-04-16 09:49:19
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);
}
标签:XMLHttpRequest
![](/images/zang.png)
![](/images/jiucuo.png)
猜你喜欢
Flask入门教程实例:搭建一个静态博客
2022-08-12 10:17:38
![](https://img.aspxhome.com/file/2023/4/94124_0s.png)
asp如何实现页面执行时间及搜索时间
2007-11-12 22:48:00
Django框架创建mysql连接与使用示例
2024-01-18 10:38:26
Python实现的检测网站挂马程序
2023-11-21 16:39:38
对Python进行数据分析_关于Package的安装问题
2021-07-29 17:23:42
![](https://img.aspxhome.com/file/2023/8/120478_0s.png)
教你一步步实现一个简易promise
2024-04-26 17:11:37
citespace数据处理:用python对Ref文档进行去重方式
2022-07-06 06:01:13
![](https://img.aspxhome.com/file/2023/4/75954_0s.jpg)
一文带你了解Python枚举类enum的使用
2022-05-27 07:46:51
python学习之基于Python的人脸识别技术学习
2021-04-23 22:09:25
详解tensorflow之过拟合问题实战
2022-08-13 00:46:30
![](https://img.aspxhome.com/file/2023/8/83688_0s.png)
Go简单实现协程方法
2024-02-06 05:00:12
![](https://img.aspxhome.com/file/2023/3/105143_0s.png)
Activiti-Explorer使用sql server数据库实现方法
2024-01-18 03:07:36
![](https://img.aspxhome.com/file/2023/7/124847_0s.png)
python opencv实现图片旋转矩形分割
2022-01-25 06:23:24
![](https://img.aspxhome.com/file/2023/6/123806_0s.jpg)
只需要这一行代码就能让python计算速度提高十倍
2023-01-30 15:16:02
![](https://img.aspxhome.com/file/2023/4/89284_0s.png)
Python中的自定义函数学习笔记
2023-11-21 15:56:56
![](https://img.aspxhome.com/file/2023/6/64336_0s.png)
MySQL索引优化之分页探索详细介绍
2024-01-16 12:05:17
![](https://img.aspxhome.com/file/2023/0/107920_0s.png)
Python matplotlib学习笔记之坐标轴范围
2022-04-21 16:24:28
![](https://img.aspxhome.com/file/2023/8/88038_0s.jpg)
三分钟学会Sql Server的复制功能[图]
2008-07-18 12:18:00
![](https://img.aspxhome.com/file/UploadPic/20087/18/2008718122618221s.gif)
MySQL5.7中 performance和sys schema中的监控参数解释(推荐)
2024-01-14 04:53:52
django项目简单调取百度翻译接口的方法
2023-10-20 18:25:41
![](https://img.aspxhome.com/file/2023/0/64280_0s.png)