ExtJS submission to the server side and simple login implementation

Source: Internet
Author: User

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

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.