我正在尝试使用 Extjs4.1 文件字段将文件发布到服务器。
但是发生错误,它说结果未定义。:(
通知,
没有文件字段,它工作正常。
这是表格。它加载正常。尝试提交时发生错误。
var myform = Ext.create('Ext.form.Panel', {
bodyStyle: 'padding: 15px 50px',
defaults: {
xtype: 'textfield',
anchor: '100%',
style : 'margin-top:10px'
},
items: [
{
xtype: 'fieldcontainer',
layout: 'hbox',
anchor: '50%',
items: [
{
xtype: 'textfield',
fieldLabel: '<b>Order Number </b>',
name: 'orderNo',
maxLength: 9,
flex: 1,
allowBlank: false
}, {
xtype: 'button',
text: 'Get Info',
name : 'getOrderInfo_btn',
tooltip: 'Get Order Information',
style: 'margin-left:5px',
flex: 0
}
]
}, {
fieldLabel: '<b>Refundable Tax Amount </b>',
name: 'refundAmount',
readOnly: true,
labelWidth: 160,
anchor: '45%',
allowBlank: false
}, {
fieldLabel: '<b>Certificate File</b>', //without this, it's OK
xtype : 'filefield',
name: 'certificate',
labelWidth: 160,
anchor: '90%',
allowBlank: false
}
.
.
.
这是我的控制器(提交表单),
refundTaxAmount: function (obj) {
var form = obj.up('panel').down('form').getForm();
console.log('Hi'); // it prints, but after that it stop with an error msg.
if (form.isValid()) {
form.submit({
waitMsg: 'Please wait, now processing...',
url: '/Order/CreditForTax/',
method: 'POST',
success: function (form, action) {
Ext.MessageBox.show({
title: 'Notice',
msg: 'The tax credit has been refunded!',
buttons: Ext.MessageBox.OK,
icon: Ext.MessageBox.INFO,
width: 300
});
form.reset();
},
failure: function (form, action) {
Ext.MessageBox.show({
title: 'Error',
msg: action.result.message,
buttons: Ext.MessageBox.OK,
icon: Ext.MessageBox.ERROR,
width: 300
});
}
});
}
}
有谁知道,我的问题是什么?请指教~!
谢谢
[编辑]
当 submit() 时,5-10 秒后,出现错误消息。
[编辑2]
ASP.NET (c#) 代码,
[HttpPost]
public JsonResult CreditForTax(RefundModel info, HttpPostedFileBase certificate)
{
object result;
try
{
//do something
result = new {success = true};
}
catch (Exception e)
{
log.Error(e.Message +"\n"+e.StackTrace);
result = new { success = false, message = e.Message };
}
return Json(result);
}
是的,我认为 asp.net 代码是错误的......有人知道该代码有什么问题吗?