Home >Web Front-end >JS Tutorial >Summary of methods for submitting data in ext form form_YUI.Ext related

Summary of methods for submitting data in ext form form_YUI.Ext related

WBOY
WBOYOriginal
2016-05-16 19:02:011311browse

EXT form ajax submission (default submission method)

Copy code The code is as follows:

1. function login(item) {
2.
3. if (validatorForm()) {
4. // Set the login button to disabled when logging in to prevent repeated submissions
5 . this.disabled = true;
6.
7. // The first parameter can be submit and load
8. formPanl.form.doAction('submit', {
9.
10. url : 'user.do?method=login',
11.
12. method : 'post',
13.
14. // If there is something other than a form Parameters can be added here. I am temporarily empty here, or you can omit the following sentence.
15. params: '',
16. form, the second one is the Ext.form.Action object used to obtain the json data passed from the server.
18. success: function(form, action) {
19.
20. Ext.Msg. alert('operation', action.result.data);
21. this.disabled = false;
22.
23. },
24. failure : function(form, action) {
25.
26. Ext.Msg.alert('Warning', 'Username or password is incorrect!');
27. // Login failed, reset the submit button to operable
28. this.disabled = false;
29.
30. }
31. });
32. this.disabled = false; }



Non-ajax submission of 2.EXT form




Copy code The code is as follows: 1. //Be sure to add the following two lines to implement non-AJAX submission form! onSubmit : Ext.emptyFn, submit : function() {
2. //Set the action address again
3. this.getEl().dom.action ='user.do?method=login'; this.getEl().dom.method = 'post';
4. //Submit
5. this.getEl().dom.submit();
6. },



Ajax submission of 3.EXT



2.
3. Ext.Ajax.request({
4. //Request address
5. url: 'login. do',
6. //Submit parameter group
7. params: {
8. LoginName:Ext.get('LoginName').dom.value,
9. LoginPassword:Ext. get('LoginPassword').dom.value
10. },
11. //Callback on success
12. success: function(response, options) {
13. //Get the response json string
14. var responseArray = Ext.util.JSON.decode(response.responseText);
15. if(responseArray.success==true){
16. Ext.Msg.alert ('Congratulations', 'You have logged in successfully!');
17. }
18. else{
19. Ext.Msg.alert('Failed', 'Login failed, please log in again' );
20. }
21. }
22. });

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn