码迷,mamicode.com
首页 > 其他好文 > 详细

ajax(4)--post

时间:2014-05-14 23:18:11      阅读:264      评论:0      收藏:0      [点我收藏+]

标签:code   java   c   ext   http   a   

<script type="text/javascript">
window.onload = function () {
gel("btnReg").onclick = function () {
//1.创建异步对象
var xhr = createXmlHttp();
//2.准备请求的url和参数
var urlPara = "05Reg.ashx";
//3.设置异步对象的请求参数
xhr.open("post", urlPara, true);
//4.如果是post方式的话,为请求报文头中 添加 Content-Type 来设置参数的编码组织方式
xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
//5.设置回调函数
xhr.onreadystatechange = function () {
if (xhr.readyState == 4 && xhr.status == 200) {
//接收返回值
var res = xhr.responseText;
if (res == "ok") {
alert("恭喜您,注册成功!");
} else {
alert("对不起,注册失败!");
}
}
};
//6.发送请求 name=james&pwd=123
xhr.send("name=" + gel("txtName").value + "&pwd=" + gel("txtPwd").value);
};
};
</script>

ajax(4)--post,布布扣,bubuko.com

ajax(4)--post

标签:code   java   c   ext   http   a   

原文地址:http://www.cnblogs.com/buzi521/p/3728815.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!