/**
Copy Code code as follows:
* The first type of AJAX submission
* This approach needs to be submitted directly using the EXT Ajax method
* Using this method, you need to encapsulate the parameters to be passed
* @return
*/
function Saveuser_ajaxsubmit1 () {
Ext.Ajax.request ({
URL: ' User_save.action ',
Method: ' Post ',
Params: {
UserName:document.getElementById (' UserName '). Value,
Password:document.getElementById (' password '). Value
},
Success:function (response, options) {
var o = Ext.util.JSON.decode (response.responsetext);
alert (o.msg);
},
Failure:function () {
}
});
}
/**
* The second type of AJAX submission
* This way will specify an HTML form for ext Ajax
* Using this method, you do not need to encapsulate the parameters to be passed
*
* @return
*/
function Saveuser_ajaxsubmit2 () {
Ext.Ajax.request ({
URL: ' User_save.action ',
Method: ' Post ',
Form: ' UserForm ',//Specify forms
Success:function (response, options) {
var o = Ext.util.JSON.decode (response.responsetext);
alert (o.msg);
},
Failure:function () {
}
});
}
/**
* The third way of submitting Ajax
* This way will be submitted for Ext's own form
* Using this method, you need to use Ext's own TextField component
*
* @return
*/
function Saveuser_ajaxsubmit3 () {
Defining a Form
var formpanel = new Ext.formpanel ({
Labelwidth:75,
Frame:true,
Bodystyle: ' padding:5px 5px 0 ',
WIDTH:350,
Defaults: {
width:230
},
DefaultType: ' TextField ',
Items: [{
Fieldlabel: ' username ',
Name: ' UserName ',
Allowblank:false
}, {
Fieldlabel: ' Password ',
Name: ' Password '
} ]
});
Definition window
var win = new Ext.window ({
Title: ' Add User ',
Layout: ' Fit ',
WIDTH:500,
HEIGHT:300,
Closeaction: ' Close ',
Closable:false,
Plain:true,
Items:formpanel,
Buttons: [{
Text: ' OK ',
Handler:function () {
var form = Formpanel.getform ();
var userName = Form.findfield (' UserName '). GetValue (). Trim ();
var password = form.findfield (' password '). GetValue (). Trim ();
if (!username) {
Alert (' User name cannot be empty ');
Return
}
if (!password) {
Alert (' Password cannot be empty ');
Return
}
Form.submit ({
Waittitle: ' Please later ... ',
Waitmsg: ' Saving user information, please later ... ',
URL: ' User_save.action ',
Method: ' Post ',
Success:function (form, action) {
alert (action.result.msg);
},
Failure:function (form, action) {
alert (action.result.msg);
}
});
}
}, {
Text: ' Cancel ',
Handler:function () {
Win.close ();
}
} ]
});
Win.show ();
}
/**
* The fourth kind of Ajax submission method
* This way translates HTML forms into Ext forms for asynchronous submission
* Using this method, you need to define a good HTML form
*
* @return
*/
function Saveuser_ajaxsubmit4 () {
New Ext.form.BasicForm (' UserForm '). Submit ({
Waittitle: ' Please later ... ',
Waitmsg: ' Saving user information, please later ... ',
URL: ' User_save.action ',
Method: ' Post ',
Success:function (form, action) {
alert (action.result.msg);
},
Failure:function (form, action) {
alert (action.result.msg);
}
});
}