请考虑以下代码。我需要在失败/成功方法中访问“原始响应文本”。我该怎么做?
myFormPanel.getForm().submit({
url: 'updateConsignment.php',
success: function(form, action) {
Ext.Msg.alert('Success', action.result.msg);
},
failure: function(form, action) {
switch (action.failureType) {
case Ext.form.action.Action.CLIENT_INVALID:
Ext.Msg.alert('Failure', 'Form fields may not be submitted with invalid values');
break;
case Ext.form.action.Action.CONNECT_FAILURE:
Ext.Msg.alert('Failure', 'Ajax communication failed');
break;
case Ext.form.action.Action.SERVER_INVALID:
Ext.Msg.alert('Failure', action.result.msg);
}
}
});
答案 0 :(得分:0)
尝试:
myFormPanel.getForm().submit({
url: 'updateConsignment.php',
success: function(form, action) {
console.log(action.result);
Ext.Msg.alert('Success', action.result.msg);
},
failure: function(form, action) {
console.log(action.result);
switch (action.failureType) {
case Ext.form.action.Action.CLIENT_INVALID:
Ext.Msg.alert('Failure', 'Form fields may not be submitted with invalid values');
break;
case Ext.form.action.Action.CONNECT_FAILURE:
Ext.Msg.alert('Failure', 'Ajax communication failed');
break;
case Ext.form.action.Action.SERVER_INVALID:
Ext.Msg.alert('Failure', action.result.msg);
}
}
});
action.result
应包含服务器的响应。
您可以使用here
所述的action.response
来获取RAW回复