ExtJS platform has been set up, then the next to do the site landing page, of course, or in the JSP page loaded ExtJS, first we first understand how ExtJS is submitted to the server side:
1, Ext form Forms AJAX Submission (default submission method)
The advantage of a separate AJAX submission is that you can omit the write parameter array, reference code
var formpanl = new Ext.formpanel ({});//The parameters inside are not written.
function Login (item) {
if (Validatorform ()) {
Log in when the login button is set to Disabled to prevent duplicate submissions
This.disabled = true;
The first parameter can be a submit and load
FormPanl.form.doAction (' Submit ', {
URL: ' Dologin.html?method=login ',
Method: ' Post ',
If there are parameters other than the form, you can add them here. I am temporarily empty here, can also be omitted from the following sentence
Params: ",
The first argument is to pass in the form, and the second is the Ext.form.Action object used to get the JSON data passed from the server side.
Success:function (form, action) {
Ext.Msg.alert (' operation ', action.result.data);
this.disabled = false;
},
Failure:function (form, action) {
Ext.Msg.alert (' warning ', ' Username or password error! ‘);
Login failed, reset the submit button to actionable
this.disabled = false;
}
});
this.disabled = false;
}
2. The non-AJAX submission of the Ext form should include the following code in the form
Implement a non-Ajax submission form Be sure to add the following two lines!
OnSubmit:Ext.emptyFn, Submit:function () {
Set the address of the action again
This.getel (). dom.action = ' dologin.html?method=login '; This.getel (). Dom.method = ' post ';
Submitted by submit
This.getel (). Dom.submit ();
}
3, ext Ajax submissions, the personal think often used a way
Ext.Ajax.request ({
URL: ' dologin.html ',//Request address
Method: ' Post ',//default Post
Submit parameter Group
Params: {
LoginName: "",
Loginpassword: ""
},
Callback when successful
Success:function (response, options) {
Gets the JSON string for the response
var jsondata = Ext.util.JSON.decode (Response.responsetext); The JSON class changed from extjs4.0 to Ext.json, and the previous Ext.util.JSON
if (jsondata.data) {
Ext.Msg.alert (' Congratulations ', ' You've successfully signed in! ‘);
} else{
Ext.Msg.alert (' failed ', ' login failed, please login again ');
}
}
});
Specific login words according to the code can be implemented on their own, basically are extjs syntax, when the login is successful, you can jump to the homepage or the specified page.
ExtJS submission to the server side and simple login implementation