Formpanel Submission Method
Ext.MessageBox.wait (' The data is being submitted, please wait a moment ... ', ' hint ');
Xxxxformpanel.getform (). Submit ({
timeout:60,
success:function (form, action) {
//Business Success
Ext.MessageBox.updateProgress (1);
Ext.MessageBox.hide ();
},
failure:function (form, action) {
//Business failure
Ext.MessageBox.updateProgress ( 1);
Ext.MessageBox.hide ();
Switch (action.failuretype) {case
Ext.form.Action.CLIENT_INVALID:
Ext.Msg.alert (' ERROR. ', ' There is no validated data! ';
break;
Case Ext.form.Action.CONNECT_FAILURE:
Ext.Msg.alert (' ERROR. ', ' connection Error! ');
break;
Case Ext.form.Action.SERVER_INVALID:
Ext.Msg.alert (' Error! ', action.result.msg);
}
}
);
How to submit Ajax
Ext.Ajax.request ({
URL: ...,
params: {
...
},
success:function (response, opts) {
var o = Ext. Util. Json.decode (response.responsetext);
if (o.success) {
//Business execution Success
} else{
//Business execution Failure
}
,
failure:function (response, opts) {
//? What to do here, you can say : oops:
}
);
Both can receive the following JSON string returned by the server side:
{success:true/false,msg: ' xxxx '}
If success is true, the program enters the success callback function for the Formpanel submission, and the program enters the success callback function for the Ajax submission method.
The difference is that if success is false, the program enters the failure callback function for the Formpanel submission, and the Ajax submission way, the program still enters the success callback function.
Summarize:
Success true and false can be used to indicate the success or failure of the business.
1, in the Formpanel submission mode, the successful operation in the success callback function, after the failure of the operation in the failure callback function;
2. In the Ajax submission method, the success of the business failure should be done in the success callback function, and true or false to o.success (see Code and comments).