当前位置: 首页 > 图文教程 > 网络编程 > Javascript > ext form 表单提交数据的方法小结

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 中的 ext form 表单提交数据的方法小结


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

Ext 表单提交数据的三种方法小结,方便利用ext提交数据的朋友 EXT的form表单ajax提交(默认提交方式)
复制代码 代码如下:

1. function login(item) {
2.
3. if (validatorForm()) {
4. // 登录时将登录按钮设为disabled,防止重复提交
5. this.disabled = true;
6.
7. // 第一个参数可以为submit和load
8. formPanl.form.doAction('submit', {
9.
10. url : 'user.do?method=login',
11.
12. method : 'post',
13.
14. // 如果有表单以外的其它参数,可以加在这里。我这里暂时为空,也可以将下面这句省略
15. params : '',
16.
17. // 第一个参数是传入该表单,第二个是Ext.form.Action对象用来取得服务器端传过来的json数据
18. success : function(form, action) {
19.
20. Ext.Msg.alert('操作', action.result.data);
21. this.disabled = false;
22.
23. },
24. failure : function(form, action) {
25.
26. Ext.Msg.alert('警告', '用户名或密码错误!');
27. // 登录失败,将提交按钮重新设为可操作
28. this.disabled = false;
29.
30. }
31. });
32. this.disabled = false;
33. }
34. }


2.EXT表单的非ajax提交
复制代码 代码如下:

1. //实现非AJAX提交表单一定要加下面的两行! onSubmit : Ext.emptyFn, submit : function() {
2. //再次设定action的地址
3. this.getEl().dom.action ='user.do?method=login'; this.getEl().dom.method = 'post';
4. //提交submit
5. this.getEl().dom.submit();
6. },

3.EXT的ajax提交
复制代码 代码如下:

1.
2.
3. Ext.Ajax.request({
4. //请求地址
5. url: 'login.do',
6. //提交参数组
7. params: {
8. LoginName:Ext.get('LoginName').dom.value,
9. LoginPassword:Ext.get('LoginPassword').dom.value
10. },
11. //成功时回调
12. success: function(response, options) {
13. //获取响应的json字符串
14. var responseArray = Ext.util.JSON.decode(response.responseText);
15. if(responseArray.success==true){
16. Ext.Msg.alert('恭喜','您已成功登录!');
17. }
18. else{
19. Ext.Msg.alert('失败','登录失败,请重新登录');
20. }
21. }
22. });