惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

T
Threatpost
V
Vulnerabilities – Threatpost
TaoSecurity Blog
TaoSecurity Blog
C
Cybersecurity and Infrastructure Security Agency CISA
P
Proofpoint News Feed
G
GRAHAM CLULEY
S
Securelist
P
Palo Alto Networks Blog
MongoDB | Blog
MongoDB | Blog
A
Arctic Wolf
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
WordPress大学
WordPress大学
Project Zero
Project Zero
T
Threat Research - Cisco Blogs
L
Lohrmann on Cybersecurity
C
Cyber Attacks, Cyber Crime and Cyber Security
F
Fortinet All Blogs
博客园 - 叶小钗
B
Blog RSS Feed
C
Cisco Blogs
Google DeepMind News
Google DeepMind News
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
Apple Machine Learning Research
Apple Machine Learning Research
G
Google Developers Blog
K
Kaspersky official blog
D
Docker
Latest news
Latest news
Cisco Talos Blog
Cisco Talos Blog
T
Tor Project blog
Cyberwarzone
Cyberwarzone
Security Latest
Security Latest
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
D
Darknet – Hacking Tools, Hacker News & Cyber Security
Spread Privacy
Spread Privacy
Microsoft Azure Blog
Microsoft Azure Blog
C
Check Point Blog
J
Java Code Geeks
Simon Willison's Weblog
Simon Willison's Weblog
T
Tenable Blog
Recent Announcements
Recent Announcements
T
Tailwind CSS Blog
H
Help Net Security
L
LINUX DO - 热门话题
T
The Exploit Database - CXSecurity.com
Jina AI
Jina AI
S
SegmentFault 最新的问题
MyScale Blog
MyScale Blog
NISL@THU
NISL@THU
美团技术团队
腾讯CDC

博客园 - 海蓝心

业余时间折腾了个微信小程序版本的街机游戏模拟器(吾爱街机),8090后的童年回忆,欢迎大家体验 Flex Formatter (flex ide 代码格式工具) 安装Android 开发工具 (二) Android 是什么 (一) 个性化印品DIY制作软件《光影21度》(.net客户端与flex通信技术) flash 电子相册 功能强大 在线传输软件 支持断点续传 flex版 个性化数码印刷在线diy 学习XSLT的知识积累 委托学习笔记二(多播委托) 委托学习笔记一(调用委托) 委托和事件— 一个虚构的故事 ASP.NET程序中常用的三十三种代码(5) ASP.NET程序中常用的三十三种代码(6) ASP.NET程序中常用的三十三种代码(3) ASP.NET程序中常用的三十三种代码(4) ASP.NET程序中常用的三十三种代码(2) ASP.NET程序中常用的三十三种代码(1) C#有关基础知识汇集
XMLHttpRequest介绍
海蓝心 · 2006-03-11 · via 博客园 - 海蓝心

XMLHttpRequest是一个客户端组件,需要在Javascript脚本中实例化后才能使用。幸运的事,这样做非常简单。在IE中,实现代码如下:

 var req = new ActiveXObject("Microsoft.XMLHTTP");

对其他的浏览器,使用:

var req = new XMLHttpRequest();

你当然想在代码中实现一些判断逻辑,有很多方法可以做到这点,但是我倾向于简单的方案,比如只是检查一下某个对象是否存在:

var req;

if (window.XMLHttpRequest) { // Non-IE browsers  

req = new XMLHttpRequest();

} else if (window.ActiveXObject) { // IE  

req = new ActiveXObject("Microsoft.XMLHTTP");

}

不管你怎么实现,上面的代码执行之后,你会发现变量req现在指向了一个XMLHttpRequest对象,这个对象有一组属性和方法,列举如下:

Property                                  Description

onreadystatechange                  Event handler for an event that fires at every state change

readyState                                Status:

0 = uninitialized

1 = loading

2 = loaded

3 = interactive

4 = complete

responseText                            Data returned from server in string form

responseXML                          DOM-compatible document object of data returned

status                                        HTTP status code (i.e., 200, 404, 500, etc.)

statusText