当前位置: 首页 > 图文教程 > 网络编程 > Javascript > Extjs ajax同步请求时post方式参数发送方式

Javascript
Add a Table to a Word Document
Add Formatted Text to a Word Document
用jscript实现新建word文档
用jscript实现新建和保存一个word文档
Open and Print a Word Document
Use Word to Search for Files
Convert Seconds To Hours
Sample script that deletes a SQL Server database
Sample script that displays all of the users in a given SQL Server DB
firefox中用javascript实现鼠标位置的定位
div+css实现鼠标放上去,背景跟图片都会变化。
Locate a File Using a File Open Dialog Box
Save a File Using a File Save Dialog Box
用jscript实现列出安装的软件列表
List the Stored Procedures in a SQL Server database
Display SQL Server Login Mode
Display SQL Server Version Information
List all the Databases on a SQL Server
用jscript启动sqlserver
Stop SQL Server

Javascript 中的 Extjs ajax同步请求时post方式参数发送方式


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-09-12   浏览: 429 ::
收藏到网摘: n/a

一般参数传递通过url后面跟后台也能取到,不过看到send参数也可以发送参数,试验了一下服务器端接受不到发送的参数,在firebug里看到发送的请求post部分是一个串,不太象正常发送的参数。 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方法里的参数串才会被服务器解释到。 "