EXT three methods for server submission

Source: Internet
Author: User

1. Three Methods of ext server submission
1. Ext form Ajax submission (default submission method)

The advantage of separate Ajax submission is that the parameter array can be omitted.

Add the button to the Click Event and execute the following method:

Java code

Java code
  1.  
    1

    . Function login (item ){
  2.  
    2

    .
  3.  
    3

    .
    If


    (Validatorform ()){
  4.  
    4

    .
    // Set the logon button to disabled during logon to prevent repeated submission

  5.  
    5

    .
    This


    . Disabled =
    True


    ;
  6.  
    6

    .
  7.  
    7

    .
    // The first parameter can be submit or load

  8.  
    8

    . Formpanl. Form. doaction (
    'Submit'

    ,{
  9.  
    9

    .
  10. 10

    . Url:
    'User. do? Method = login'

    ,
  11. 11

    .
  12. 12

    . Method:
    'Post'

    ,
  13. 13

    .
  14. 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. 15

    . Params:
    ''

    ,
  16. 16

    .
  17. 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. 18

    . Success: function (Form, Action ){
  19. 19

    .
  20. 20

    . Ext. msg. Alert (
    'Operation'

    , Action. Result. data );
  21. 21

    .
    This


    . Disabled =
    False


    ;
  22. 22

    .
  23. 23

    .},
  24. 24

    . Failure: function (Form, Action ){
  25. 25

    .
  26. 26

    . Ext. msg. Alert (
    'Shanghai'

    ,
    'User name or Password error! '

    );
  27. 27

    .
    // Logon Failed. Set the submit button to operable.

  28. 28

    .
    This


    . Disabled =
    False


    ;
  29. 29

    .
  30. 30

    .}
  31. 31

    .});
  32. 32

    .
    This


    . Disabled =
    False


    ;
  33. 33

    .}
  34. 34

    .}
1. function login (item) {2. 3. if (validatorform () {4. // set the logon button to disabled during logon to prevent repeated submission. 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. // you can add parameters other than the form. I am currently blank. You can also omit the following sentence 15. params: '', 16. 17. // The first parameter is to input this form, and the second parameter is Ext. form. the action object is used to obtain JSON data 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 ', 'user name or password is incorrect! '); 27. // Login 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

Add the following code to the form:

Code

Java code
  1. 1

    .
    // The following two rows must be added for non-Ajax form submission! Onsubmit: Ext. emptyfn, submit: function (){


  2. 2

    .
    // Set the action address again

  3. 3

    .
    This


    . Getel (). Dom. Action =
    'User. do? Method = login'

    ;
    This


    . Getel (). Dom. method =
    'Post'

    ;
  4. 4

    .
    // Submit a submit

  5. 5

    .
    This


    . Getel (). Dom. Submit ();
  6. 6

    .},
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 5. this. getel (). dom. submit (); 6 .},

3. Ajax submission of ext

Code

Java code
  1.  
    1

    .
  2.  
    2

    .
  3.  
    3

    . Ext. Ajax. Request ({
  4.  
    4

    .
    // Request address

  5.  
    5

    . Url:
    'Login. Do'

    ,
  6.  
    6

    .
    // Submit the parameter group

  7.  
    7

    . Params :{
  8.  
    8

    . Loginname: Ext. Get (
    'Loginname'

    ). Dom. value,
  9.  
    9

    . Loginpassword: Ext. Get (
    'Loginpassword'

    ). Dom. Value
  10. 10

    .},
  11. 11

    .
    // Callback upon success

  12. 12

    . Success: function (response, options ){
  13. 13

    .
    // Obtain the response JSON string

  14. 14

    . Var responsearray = ext. util. JSON. Decode (response. responsetext );
  15. 15

    .
    If


    (Responsearray. Success =
    True


    ){
  16. 16

    . Ext. msg. Alert (
    'Congratulations'

    ,
    'You have successfully logged on! '

    );
  17. 17

    .}
  18. 18

    .
    Else


    {
  19. 19

    . Ext. msg. Alert (
    'Failed'

    ,
    'Logon failed. Please log on again'

    );
  20. 20

    .}
  21. 21

    .}
  22. 22

    .});
1. 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 12 when the call is successful. 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 ('Congratulations, 'you have successfully logged on! '); 17 .} 18. else {19. ext. MSG. alert ('failed', 'logon failed, please log on again '); 20 .} 21 .} 22 .});

2. Using viewport to Layout System Menu jumps in the left Area

1. Use Ext. Get ('centerpanel '). Load (URL: "AAA. jsp"). If URL is a required parameter, see the API documentation for other optional parameters. Disadvantage: the added page JS is invalid.
2. Use IFRAME.
JS Code
Ext. Get ('centerpanel '). Dom. innerhtml =' <I f r a m e src = aaa. jsp> </I f r a m E> ';
You can dynamically load JS scripts on the loaded page (recommended)

I am a beginner, and it is inevitable that there are errors or errors. Please help me to point out.

If the original article is reprinted, please note: Reprinted from: Feiyang tribe programming warehouse
: Http://www.busfly.cn/csdn/

Link: http://www.busfly.cn/csdn/post/653.html

If you like this article, please repeat it and support me. Your support is the greatest motivation for me to continue sending the article. Thank you.
Please share some good things. Please send this article to your friends ~!~

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.