我能够在firebug中看到json响应,但是当我成功解码表单的ACTION时,它给出了undefined。
{
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);
}
});
}
}
}]
}
我的网址返回json响应我希望在提交成功时处理它。如果有人试过,请告诉我
答案 0 :(得分:4)
尝试简单的JavaScript方式
var data= JSON.parse(action.response.responseText);
或ExtJs 3.x方式
var data= Ext.util.JSON.decode(action.response.responseText);
用于ExtJs 4及以上
var data= Ext.JSON.decode(action.response.responseText);
答案 1 :(得分:1)
success : function(response, opts)
{
response = Ext.decode(response.responseText);
if(response.success==true){
alert("Authentication sucess");
}else{
Ext.MessageBox.alert('Alert','Invalid User name or password');
}
},
failure:function(response, opts)
{
Ext.MessageBox.alert('Alert','Exception is occured please contact administrator');
}