EXTJS 4如何在表单提交成功后获得Json响应?
我能够在firebug中看到json响应,但当我解码表单成功时,它的给出是未定义的EXTJS 4如何在表单提交成功后获得Json响应?,extjs,Extjs,我能够在firebug中看到json响应,但当我解码表单成功时,它的给出是未定义的 { xtype: 'form', x: 30, y: 520, height: 80, bodyPadding: 10, title: 'myuploadform', fileUpload: true, standardSubmit: false, autoHeight: true, bodyStyle: 'padding: 10px
{
xtype: 'form',
x: 30,
y: 520,
height: 80,
bodyPadding: 10,
title: 'myuploadform',
fileUpload: true,
standardSubmit: false,
autoHeight: true,
bodyStyle: 'padding: 10px 10px 10px 10px;',
labelWidth: 50,
items:[{
xtype: 'fileuploadfield',
id: 'filedata',
emptyText: 'Select a document to upload...',
fieldLabel: 'File',
buttonText: 'Browse'
}],
buttons: [{
text: 'Upload',
handler: function() {
var form = this.up('form').getForm();
if(form.isValid()){
alert("submit");
form.submit({
url: 'myurl'
waitMsg: 'Uploading file...',
success: function (form,action) {
var data= Ext.JSON.decode(action.response.responseText);
alert("Success: " + data.msg);
Ext.Msg.alert('Success', action.result.message);
},
failure: function (form, action) {
var data = Ext.decode(action.response.responseText);
alert("Failure: " + data.msg);
}
});
}
}
}]
}
我的url返回我希望在提交成功时处理的json响应。如果有人尝试过,请让我知道尝试简单的JavaScript方式
var data= JSON.parse(action.response.responseText);
或者extjs3.x方式
var data= Ext.util.JSON.decode(action.response.responseText);
对于ExtJS4及以上版本
var data= Ext.JSON.decode(action.response.responseText);
尝试简单的JavaScript方式
var data= JSON.parse(action.response.responseText);
或者extjs3.x方式
var data= Ext.util.JSON.decode(action.response.responseText);
对于ExtJS4及以上版本
var data= Ext.JSON.decode(action.response.responseText);
在ExtJS 4(至少4.2.2)中,JSON被升级,不再是og util的一部分,您必须使用:var data=Ext.JSON.decode(action.response.reponseText)在ExtJS 4(至少4.2.2)中,JSON被升级,不再是og util的一部分,您必须使用:var data=Ext.JSON.decode(action.response.reponseText)为了执行成功处理程序,响应json应该包含“success:true”。为了执行成功处理程序,响应json应该包含“success:true”。