ajax中的open()和send()方法的区别
来源:互联网 发布:vr后期制作软件 编辑:程序博客网 时间:2024/06/06 04:57
AJax中open()和send()的区别
(1)用open可以指定get,post
一般情况下,使用Ajax提交的参数多是些简单的字符串,可以直接使用GET方法将要提交的参数写到open方法的url参数中,此时send方法的参数为null。
例如 :
var url = "login.jsp?user=XXX&pwd=XXX";
xmlHttpRequest.open("GET",url,true);
xmlHttpRequset.send(null);
(2)send发送为POST请求
此 外,也可以使用send方法传递参数。使用send方法传递参数使用的是POST方法,需要设定Content-Type头信息,模拟HTTP POST方法发送一个表单,这样服务器才会知道如何处理上传的内容。参数的提交格式和GET方法中url的写法一样。设置头信息前必须先调用open方 法。
例如:
xmlHttpRequest.open("POST","login.jsp",true);
xmlHttpRequest.setRequestHeder("Content-Type","application/x-www-form-urlencoded;charset=UTF-8");
xmlHttpRequest.send("user="+username+"&pwd="+password);
在post方法上、我并没有能按上面实现、而是直接把方法改成post,路径也没有修改、就和GET一样
- ajax中的open()和send()方法的区别
- ajax的open和send
- ajax的open和send
- Ajax XMLHttpRequest对象的三个属性以及open和send方法AJAX
- Ajax XMLHttpRequest对象的三个属性以及open和send方法
- Ajax XMLHttpRequest对象的三个属性以及open和send方法
- Ajax XMLHttpRequest对象的三个属性以及open和send方法
- Ajax XMLHttpRequest对象的三个属性以及open和send方法
- Ajax XMLHttpRequest对象的三个属性以及open和send方法
- Ajax XMLHttpRequest对象的三个属性以及open和send方法
- Ajax中的send采用的方法
- ajax的send方法
- handler中send和post方法的区别
- Handler里send和post方法的区别
- ajax xmlhttp下open方法POST、GET参数的区别
- send和sendto的区别
- Ajax中send方法参数的使用
- Ajax中send方法参数的使用
- Pange Rank 和它的数学模型
- IT 行业的创新 - 创新的迷思
- Bing Maps进阶系列九:使用MapCruncher进行地图切片并集成进Bing Maps
- 一个处理SQL语句的Object对象
- Debugging Native Code
- ajax中的open()和send()方法的区别
- Debugging with tcpdump and other tools
- 《计算机教育》杂志:培养“狼”一样的学生 米老师和他的信息技术提高班
- Ubuntu右键打开终端
- 云程序备援--CAP
- Visual C++线程同步技术剖析:临界区,时间,信号量,互斥量
- Google推短信收发邮件服务Gmail SMS 造福非洲人民
- 如何解包/编辑/打包boot.img文件
- Zend Framework 引导启动 – Bootstrapping