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

Javascript
form中限制文本字节数js代码
use jscript with List Proxy Server Information
use jscript List Installed Software
List Installed Software Features
List Information About the Binary Files Used by an Application
List the Codec Files on a Computer
List the UTC Time on a Computer
List Installed Hot Fixes
excel操作之Add Data to a Spreadsheet Cell
Add Formatted Data to a Spreadsheet
Apply an AutoFormat to an Excel Spreadsheet
JavaScript语法着色引擎(demo及打包文件下载)
类之Prototype.js学习
一款JavaScript压缩工具:X2JSCompactor
iis6+javascript Add an Extension File
jscript之Open an Excel Spreadsheet
jscript之Read an Excel Spreadsheet
jscript之List Excel Color Values
去除图像或链接黑眼圈的两种方法总结
Add a Formatted Table to a Word Document

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


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-09-12   浏览: 452 ::
收藏到网摘: 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方法里的参数串才会被服务器解释到。 "