1. Ext form Ajax submission (default submission method) 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 forms1. // 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 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 .});