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
. 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 (
'Shanghai'
,
'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
.}
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
.
// 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 a submit
- 5
.
This
. Getel (). Dom. Submit ();
- 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
.
-
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 (
'Congratulations'
,
'You have successfully logged on! '
);
- 17
.}
- 18
.
Else
{
- 19
. Ext. msg. Alert (
'Failed'
,
'Logon failed. Please log on again'
);
- 20
.}
- 21
.}
- 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 ~!~