Extjs ajax同步请求时post方式参数发送方式
作者:bea
ajax同步请求一般下面这样: 代码如下: var conn = Ext.lib.Ajax.getConnectionObject().conn; conn.open("POST", 'http://localhost:8080/struts2study/TreeDDGet?node=-1',false); // 这里的conn对象其实就是 xmlHttpRequest 对象。 conn.setRequestHeader("Content-Type","app
ajax同步请求一般下面这样:
代码如下:
var conn = Ext.lib.Ajax.getConnectionObject().conn;
conn.open("POST", 'http://localhost:8080/struts2study/TreeDDGet?node=-1',false);
// 这里的conn对象其实就是 xmlHttpRequest 对象。
conn.setRequestHeader("Content-Type","application/x-www-form-urlencoded;charset=UTF-8");
conn.send("start=" + 0 + "&limit=" + 30 );
var rootJson = conn.responseText;
一般参数传递通过url后面跟后台也能取到,不过看到send参数也可以发送参数,试验了一下服务器端接受不到发送的参数,在firebug里看到发送的请求post部分是一个串,不太象正常发送的参数。搜索了很久也没有找到方法,后来搜到一篇文章介绍了xmlHttpRequest对象的send方法解释,才知道需要设置一个header属性Content-Type 告诉服务器是form方式发送数据,然后send方法里的参数串才会被服务器解释到。
有用 | 无用
代码如下:
var conn = Ext.lib.Ajax.getConnectionObject().conn;
conn.open("POST", 'http://localhost:8080/struts2study/TreeDDGet?node=-1',false);
// 这里的conn对象其实就是 xmlHttpRequest 对象。
conn.setRequestHeader("Content-Type","application/x-www-form-urlencoded;charset=UTF-8");
conn.send("start=" + 0 + "&limit=" + 30 );
var rootJson = conn.responseText;
一般参数传递通过url后面跟后台也能取到,不过看到send参数也可以发送参数,试验了一下服务器端接受不到发送的参数,在firebug里看到发送的请求post部分是一个串,不太象正常发送的参数。搜索了很久也没有找到方法,后来搜到一篇文章介绍了xmlHttpRequest对象的send方法解释,才知道需要设置一个header属性Content-Type 告诉服务器是form方式发送数据,然后send方法里的参数串才会被服务器解释到。
有用 | 无用
猜你喜欢
您可能感兴趣的文章:
- JavaScript 十六进制RGB色码转换器
- JQuery jsonp 使用示例代码
- Javascript array类 数组操作方法
- 上传图片时JS自动显示图片
- Javascript+XMLHttpRequest+asp.net无刷新读取数据库数据
- javascript 当前日期加(天、周、月、年)
- javascript 局部页面打印实现代码
- jQuery 解析xml文件
- ext 代码生成器
- JavaScript 变量作用域及闭包
- JavaScript 的方法重载效果
- JQuery 小练习(实例代码)
- js正确获取元素样式详解
- JavaScript 乱码问题
- jquery ui dialog里调用datepicker的问题
- jquery select(列表)的操作(取值/赋值)
- asp(javascript)全角半角转换代码 dbc2sbc
- javascript Array.remove() 数组删除
- 实现连缀调用的map方法(prototype)