码迷,mamicode.com
首页 > Web开发 > 详细

XMLHttpRequest发送请求

时间:2015-09-29 16:45:15      阅读:163      评论: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
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!