前台success: function(response, options) {
Ext.Msg.alert('提示', '成功');
var responseArray = Ext.util.JSON.decode(response.responseText);
financeForm.getForm().findField('balance').setValue(responseArray.id);
},
failure: function(response, options){
Ext.Msg.alert('提示', '失败');
financeForm.getForm().findField('balance').setValue("0");
}
});
后台if (financeList.isEmpty()) {
jsonString = "{success:false, msg:'保存!'}"; } else {
for (int index = 0; index < financeList.size(); index++) {
String balan = financeList.get(index).getBalance();
jsonString = "{id:'" + balan + "',success:true, msg:'保存!'}"; }
}
不管后台返回的json是真{id:'" + balan + "',success:true, msg:'保存!'}还是假{success:false, msg:'保存!'},在前台都是执行success:中函数
压根就没执行failure中的函数!
急急急急.......................!
Ext.Msg.alert('提示', '成功');
var responseArray = Ext.util.JSON.decode(response.responseText);
financeForm.getForm().findField('balance').setValue(responseArray.id);
},
failure: function(response, options){
Ext.Msg.alert('提示', '失败');
financeForm.getForm().findField('balance').setValue("0");
}
});
后台if (financeList.isEmpty()) {
jsonString = "{success:false, msg:'保存!'}"; } else {
for (int index = 0; index < financeList.size(); index++) {
String balan = financeList.get(index).getBalance();
jsonString = "{id:'" + balan + "',success:true, msg:'保存!'}"; }
}
不管后台返回的json是真{id:'" + balan + "',success:true, msg:'保存!'}还是假{success:false, msg:'保存!'},在前台都是执行success:中函数
压根就没执行failure中的函数!
急急急急.......................!
failurey:function(response,status){}
success: function (response) {
var result = Ext.decode(response.responseText);
if (result.success) {//这个success才是你后台那个!!!!!
} else {
}
}
后台如果遇到编译 或者异常就跳到failure
Ext.Ajax.request({
callback: function(option, success, response) {//使用callback函数,failure只会在http请求失败时调用 ,比如找不到请求的url
var res = Ext.decode(response.responseText);
if (success && res.success) {
}else {
alert("失败");
}
})