ext form 表單提交資料的方法小結_YUI.Ext相關

來源:互聯網
上載者:User
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. }); 

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.