首页 > Web开发 > 详细

XMLHttpRequest发送请求

时间:2015-09-29 16:43:52      阅读:143      评论:0      收藏:0      [点我收藏+]

*open(method,url,async)

*send(string)//在使用get请求的时候,是没有主体的,所有的信息都会拼在url当中,所以使用send的时候括号里的string可以为空!如果是使用post请求,这个send就一定要填写参数,不然就没有什么意义。
 
request.open("get","get.php",true);//get请求
request.send();//在发送出去
 
request.open("post","post.php",true);//post请求
request.send();//无参数,无意义。
 
request.open("post","create.php",true);//post请求
request.setRequestHeader("Content-type","application/x-www-form-urlencoded");//设置http的头信息,告诉服务器我们要发送一个表单。
request.send("name=王二狗&sex=男");//发送请求的响应体。

XMLHttpRequest发送请求

原文:http://www.cnblogs.com/Yirannnnnn/p/4846385.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!