XMLHttpRequest和ActiveXObject学习
来源:互联网 发布:死而后已不亦远乎 编辑:程序博客网 时间:2024/06/15 13:48
//var xmlHttpReq = new ActiveXObject("MSXML2.XMLHTTP.3.0");
//定义变量,存储对象
var xmlHttp;
// 创建XMLHttpRequest对象
if (window.ActiveXObject) {
xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
} else if (window.XMLHttpRequest) {
xmlHttpReq = new XMLHttpRequest();
}
xmlHttpReq.open("GET", "http://localhost:9090/html5/test", false);
xmlHttpReq.onreadystatechange = handleStateChange;
xmlHttpReq.send();
// xmlHttpReq.responseText
// xmlHttpReq.responseXML
var htmlObj = "";
htmlObj += "=============状态码=================<br>";
htmlObj += "status=" + xmlHttpReq.status + "<br>";
htmlObj += "statusText=" + xmlHttpReq.statusText + "<br>";
htmlObj += "=============头信息=================<br>";
htmlObj += "heads=" + xmlHttpReq.getAllResponseHeaders() + "<br>";
htmlObj += "Content-Length=" + xmlHttpReq.getResponseHeader("Content-Length") + "<br>";
htmlObj += "=============返回信息=================<br>";
htmlObj += "responseStream=" + xmlHttpReq.responseStream + "<br>";
var obj = document.getElementById("showDiv");
obj.innerHTML = htmlObj;
function handleStateChange() {
// 请求的状态有5个值:0=未初始化;1=正在加载;2=已经加载;3=交互中;4=完成;
if (xmlHttpReq.readyState == 4) {
// 200对应OK,如404=未找到网页
if (xmlHttpReq.status == 200) {
// alert(xmlHttpReq.responseText);
}
}
}
//定义变量,存储对象
var xmlHttp;
// 创建XMLHttpRequest对象
if (window.ActiveXObject) {
xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
} else if (window.XMLHttpRequest) {
xmlHttpReq = new XMLHttpRequest();
}
xmlHttpReq.open("GET", "http://localhost:9090/html5/test", false);
xmlHttpReq.onreadystatechange = handleStateChange;
xmlHttpReq.send();
// xmlHttpReq.responseText
// xmlHttpReq.responseXML
var htmlObj = "";
htmlObj += "=============状态码=================<br>";
htmlObj += "status=" + xmlHttpReq.status + "<br>";
htmlObj += "statusText=" + xmlHttpReq.statusText + "<br>";
htmlObj += "=============头信息=================<br>";
htmlObj += "heads=" + xmlHttpReq.getAllResponseHeaders() + "<br>";
htmlObj += "Content-Length=" + xmlHttpReq.getResponseHeader("Content-Length") + "<br>";
htmlObj += "=============返回信息=================<br>";
htmlObj += "responseStream=" + xmlHttpReq.responseStream + "<br>";
var obj = document.getElementById("showDiv");
obj.innerHTML = htmlObj;
function handleStateChange() {
// 请求的状态有5个值:0=未初始化;1=正在加载;2=已经加载;3=交互中;4=完成;
if (xmlHttpReq.readyState == 4) {
// 200对应OK,如404=未找到网页
if (xmlHttpReq.status == 200) {
// alert(xmlHttpReq.responseText);
}
}
}
0 0
- XMLHttpRequest和ActiveXObject学习
- XMLHttpRequest和ActiveXObject学习
- AJAX学习系列1--XMLHttpRequest对象和ActiveXObject对象
- XMLHttpRequest与ActiveXObject
- ActiveX,ActiveXObject , xmlHttpRequest , ajax
- window.XMLHttpRequest an window.ActivexObject
- 学习 XMLHTTPRequest 和 AJAX
- ActiveXObject
- ActiveXObject
- ActiveXObject
- ActiveXObject
- ActiveXObject
- ActiveXObject
- XmlHttp对象学习--------ActiveXObject 对象
- ajax学习笔记---XMLHttpRequest的属性和方法
- ajax学习-创建XMLHttpRequest
- XMLHttpRequest学习笔记
- XMLHttpRequest学习笔记一
- LeetCode Construct Binary Tree from Inorder and Postorder Traversal
- 重复字符统计算法
- 数组在程序设计中,为了处理方便, 把具有相同类型的若干变量按有序的形式组织起来。这些按序排列的同类数据元素的集合称为数组
- intelliJ IDEA 10的使用简要
- itoa 库函数的实现
- XMLHttpRequest和ActiveXObject学习
- Pocketsphinx语音识别--使用流程, 安装,使用
- 关于OnPaint, OnEraseBkGnd, WM_PAINT,WM_ERASEBKGND
- asio学习之三:asio实现简单的服务器和客户端
- 在两个有序链表中查找第K大元素。
- 设计模式------------装饰者模式
- extern用法
- org.hibernate.MappingException: Unknown entity:
- Xcode 升级后,常常遇到的遇到的错误解决方法