First:
Ext. getcmp ("save"). On ('click', loginfun); // when you click the Save button with the ID, run the loginfun function.
Function loginfun (){
VaR W = ext. getcmp ("_ window ");
VaR F = ext. getcmp ("modifyform"); // obtain the component
VaR newpwd = ext. getcmp ("newpwd"). getvalue (); // Value
VaR oldpwd = ext. getcmp ("oldpwd"). getvalue ();
VaR confirm = ext. getcmp ("Confirm"). getvalue ();
If (newpwd! = Confirm ){
Ext. msg. Alert ('inconsistent passwords entered twice ');
} Else {
VaR para = {// Parameter
Oldpwd: oldpwd,
Newpwd: newpwd
};
VaR url = 'userinfo. do? Method = changepwd '; // The actionurl to be submitted
Ext. Ajax. Request ({// Ajax submit
URL: URL,
Params: Para,
Method: 'post ',
Success: function (XMLHTTP, request) {// submit the server return value
Res = ext. util. JSON. Decode (XMLHTTP. responsetext );
If (res. Result = 'success') {// return value of action
W. Close ();
Ext. msg. Alert ('success', 'password changed! ');
} Else {
W. Close ();
Ext. msg. Alert ('failed', 'the original password is incorrect! ');
}
},
Failure: function (XMLHTTP, request ){
W. Close ();
Ext. msg. Alert ('error', "server error ");
}
});
}
}
Second:
Ext. getcmp ("save"). On ('click', submit); // when you click the Save button with the ID, run the loginfun function.
function submit () {
var W = ext. getcmp ("_ window");
var F = ext. getcmp ("userform");
F. form. submit ({// form submission
URL: 'userinfo. do? Method = save ',
method: 'post',
success: function (Form, Action) {
W. close ();
Ext. MSG. alert ('success', 'successfully');
},
failure: function (Form, Action) {
W. close ();
Ext. MSG. alert ('failed', 'failed');
}< BR >});
}