How to submit data in extform form: _ YUI. Ext

Source: Internet
Author: User
There are three methods to submit data in the Ext form to facilitate the ajax submission of the form of the friend ext who submits data using EXT (default submission method)

The Code is as follows:


1. function login (item ){
2.
3. if (validatorForm ()){
4. // set the logon button to disabled during logon to prevent repeated submission.
5. this. disabled = true;
6.
7. // The first parameter can be submit or load
8. formPanl. form. doAction ('submit ',{
9.
10. url: 'user. do? Method = login ',
11.
12. method: 'post ',
13.
14. // if there are parameters other than the form, you can add them here. I am currently blank. You can also omit the following sentence.
15. params :'',
16.
17. // The first parameter is to pass in the form, and the second is the Ext. form. Action object used to obtain the json data transmitted by 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 ', 'user name or Password error! ');
27. // Logon Failed. Set the submit button to operable.
28. this. disabled = false;
29.
30 .}
31 .});
32. this. disabled = false;
33 .}
34 .}




2. Non-ajax submission of EXT forms

The Code is as follows:


1. // The following two rows must be added for non-AJAX form submission! 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 the submit
5. this. getEl (). dom. submit ();
6 .},



3. ajax submission of EXT

The Code is as follows:


1.
2.
3. Ext. Ajax. request ({
4. // request address
5. url: 'login. do ',
6. // submit the parameter group
7. params :{
8. LoginName: Ext. get ('loginname'). dom. value,
9. LoginPassword: Ext. get ('loginpassword'). dom. value
10 .},
11. // callback upon success
12. success: function (response, options ){
13. // obtain the response json string
14. var responseArray = Ext. util. JSON. decode (response. responseText );
15. if (responseArray. success = true ){
16. Ext. Msg. alert ('congratulation ',' you have successfully logged on! ');
17 .}
18. else {
19. Ext. Msg. alert ('failed', 'logon failed, please log on again ');
20 .}
21 .}
22 .});

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.