我正在使用Extjs4.1文件域将文件发布到服务器。Extjs4,文件上传
但发生错误,说结果是未定义的。 :(
在形式上,
没有FileField字段,它工作得很好。”
这是形式,并将其加载确定。出现错误时尝试提交。
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
});
}
});
}
}
有人知道,我的问题是什么?请指教我〜!
由于
[编辑]
提交时(),5-10秒后,错误消息发生。
[EDIT2]
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代码是错误的...任何人都知道那个代码有什么问题?
您能否澄清在提交表单之前是否发生错误,或者文件是否已提交给服务器,但响应没有正确解析? – dbrin 2012-07-12 18:40:06
没有提交错误发生之前,所以最后不能发布它。 – 2012-07-12 18:52:09
调用堆栈的样子是什么?它在做什么以及实际发生错误的位置? – dbrin 2012-07-12 19:01:52