Ext form Forms Form AJAX Submission (default submission method)
Copy Code code as follows:
1. Function login (item) {
2.
3. if (Validatorform ()) {
4.//Login button set to Disabled to prevent duplicate submission
5. this.disabled = true;
6.
7.//The first parameter can be submit and load
8. FormPanl.form.doAction (' Submit ', {
9.
URL: ' User.do?method=login ',
11.
Method: ' Post ',
13.
14.//If there are other parameters other than the form, you can add it here. I am temporarily empty here, can also be omitted from the following sentence
Params: ',
16.
17.//The first parameter is to pass in the form, and the second is the Ext.form.Action object used to get the JSON data from the server.
Success:function (form, action) {
19.
Ext.Msg.alert (' operation ', action.result.data);
this.disabled = false;
22.
23.},
Failure:function (form, action) {
25.
Ext.Msg.alert (' warning ', ' username or password is wrong!) ');
27.//Login failure, reset the submit button to be operable
this.disabled = false;
29.
30.}
31.});
this.disabled = false;
33.}
34.}
Non-Ajax submissions for 2.EXT forms
Copy Code code as follows:
1.//Implement non-Ajax submission form must add the following two lines! OnSubmit:Ext.emptyFn, Submit:function () {
2.//Reset the action address again
3. This.getel (). dom.action = ' user.do?method=login '; This.getel (). Dom.method = ' post ';
4. Submit Submission
5. This.getel (). Dom.submit ();
6.},
3.EXT of Ajax submission
Copy Code code as follows:
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 when successful
Success:function (response, options) {
13.//Get the response's JSON string
var Responsearray = Ext.util.JSON.decode (Response.responsetext);
if (responsearray.success==true) {
Ext.Msg.alert (' Congratulations ', ' You have successfully logged in! ');
17.}
else{
Ext.Msg.alert (' failed ', ' login failed, please login ');
20.}
21.}
22.});