1215整理
2015-12-16 19:54
225 查看
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>无标题文档</title> <script language="javascript" > //IE //var h= new ActiveXObject("Msxml2.XMLHTTP"); //var p= new ActiveXObject("Microsoft.XMLHTTP"); //非IE //var f = new XMLHTTPRequest(); //通用代码 var hx; if(window.XMLHttpRequest)//非IE,IE7及以上 { hx= new XMLHttpRequest(); alert("以new XMLHttpRequest()形式创建"); } else if(window.ActiveXObject) //IE { try { hx= new ActiveXObject("Msxml2.XMLHTTP"); alert("以Msxml2.XMLHTTP形式创建"); } catch(e) { alert(e); try { hx= new ActiveXObject("Microsoft.XMLHTTP"); alert("以Microsoft.XMLHTTP形式创建"); } catch(e) { alert(e); } } } if(!hx) { alert("创建XMLHttpRequest失败"); } else { alert("创建XMLHttpRequest成功"); } //1.设置异步请求的URL等信息 请求方法,URL,请求方式(是否异步) hx.open("POST","ajaxTest",true); //2.设置回调函数,事件处理器 hx.onreadystatechange = getResult; //get //hx.send(null); hs.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); //post hx.send("userid=abc"); //alert("Server" + hx.getAllResponceHeaders("Server")); function getResult() { //1-判断请求状态 //alert("readyState=" + hx.readyState); if (hx.readyState == 4) { if (hx.status == 200) { alert("回调信息=" + hx.responseText) } else { alert("错误代码=" + hx.status + "" + hx.statusText); } } } </script> </head> <body> </body> </html>
View Code
![](http://images2015.cnblogs.com/blog/816017/201512/816017-20151216195323193-1183699465.png)
相关文章推荐
- 头结点
- as为jar包关联源码
- MySQL 索引、试图、存过、函数、触发器
- 证明:素数对中间的数能被6整除
- Leetcode题解(十四)
- IOS吐槽狂人:UITabelView全局表头和每个分区的表头和大小,设置区分表头的标题
- 相机模型详解
- 升级gcc4.4.7升级gcc4.8
- java集合——集合框架
- (my)sql 入门基础
- 【C#/OpenGL】基于DEM数据的3D地形绘制(基于CSGL)
- 页面统计
- vim查看及修改二进制
- 阿里云内网文件传输总结
- 有趣的keil MDK细节
- Remove Duplicate Letters leetCode316
- Mad Lib程序
- Android倒计时器——CountDownTimer
- Oracle定义常量和变量
- leetcode Add Two Numbers