XMLHttpRequest对象
2007-08-25 19:33
162 查看
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
// 创建XMLHttpRequest对象的一个实例;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
var xmlHttp;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
function createXMLHttpRequest()
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedBlock.gif)
...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
if (window.ActiveXObject)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
else if (window.XMLHttpRequest)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
xmlHttp = new XMLHttpRequest();
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif)
标准XMLHttpRequest方法#region 标准XMLHttpRequest方法
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
void open(string method, string url, boolean asynch, string username, string password)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
// method = "GET" | "POST" | "PUT";
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
// asynch = true | false;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
void send(content)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
// 如果是异步, 这个方法会立刻返回; 否则一直到接收到响应为止;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
// content = DOM | Input Stream | string;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
void setRequestHeader(string header, string value)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
// 这个方法必须在调用open()之后才能调用;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
void abort() ...{}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
string getAllResponseHeaders() ...{}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
string getResponseHeader() ...{}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockEnd.gif)
#endregion
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif)
标准XMLHttpRequest属性#region 标准XMLHttpRequest属性
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
// onreadystatechange: 事件处理器, 状态改变时触发;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
// readyState: 0, 未初始化; 1, 正在加载; 2, 已经加载; 3, 交互中; 4, 完成;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
// responseText: 服务器的串响应;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
// responseXML: 服务器的XML响应;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
// status: 服务器的HTTP状态码(例如: 200为OK, 404为Not Found等等);
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
// statusText: 服务器的HTTP状态字串(例如: OK, Not Found等等);
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockEnd.gif)
#endregion
相关文章推荐
- XMLHttpRequest对象的理解
- Ajax中XMLHttpRequest对象的使用
- XmlHttpRequest 对象 详解
- 掌握 Ajax,第 3 部分: Ajax 中的高级请求和响应 全面理解 HTTP 的状态代码、就绪状态和 XMLHttpRequest 对象
- XHR——XMLHttpRequest对象
- AJAX核心对象-- XMLHttpRequest 对象使用详解 (二)
- XMLHttpRequest对象的属性和方法
- XMLHttpRequest对象发送请求后,请求的状态有几个值,每个值代表什么意思?
- 全面剖析XMLHttpRequest对象
- XMLHttpRequest对象和事件
- XMLHttpRequest 对象
- Ajax创建XMLHttpRequest对象通用方法
- XMLHttpRequest对象
- JavaScript的XMLHttpRequest对象
- 对象XMLHttpRequest.readystate和Status对照
- IE7提供XMLHttpRequest对象为兼容
- Ajax之XmlHttpRequest对象
- 学习Ajax之XMLHttpRequest对象
- 2.1 4000 XMLHttpRequest对象概述
- AJAX XMLHttpRequest对象详解