Extjs4,文件上传

Extjs4,文件上传,extjs,extjs4,filefield,Extjs,Extjs4,Filefield,我尝试使用Extjs4.1文件字段将文件发布到服务器 但出现了一个错误,它表示结果未定义( 在形式上, 如果没有filefield,它就可以正常工作。” 这是表单。它加载正常。尝试提交时出错 var myform = Ext.create('Ext.form.Panel', { bodyStyle: 'padding: 15px 50px', defaults: { xtype: 'textfield', anchor: '100%',

我尝试使用Extjs4.1文件字段将文件发布到服务器

但出现了一个错误,它表示结果未定义(

在形式上,

如果没有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
    }
    .
    .
    .
有人知道,我有什么问题吗?请指点我~

谢谢

[编辑]

提交()时,5-10秒后会出现错误消息

[编辑二]

ASP.NET(c#)代码


是的,我认为asp.net代码是错误的……有人知道该代码有什么问题吗?

如果服务器正在使用
JSON
发送返回对象,则
内容类型
标题必须设置为
“text/html”
,以便告诉浏览器将未更改的文本插入到文档正文中

C#(MVC3)代码:

var jsonResponse = Json( new
                        {
                            success = false,
                            message = "Oops. There was an unexpected error.\n" + ex.ToString()
                        });
jsonResponse.ContentType = "text/html"; // <-- Set content type explicitly.
return jsonResponse;   
var jsonResponse=Json(新
{
成功=错误,
message=“Oops.出现意外错误。\n”+ex.ToString()
});

jsonResponse.ContentType=“text/html”;//您能否澄清错误是否发生在表单提交之前,或者文件是否已提交到服务器,但响应未得到正确解析?在提交之前没有,因此最终无法发布错误。调用堆栈是什么样子的?它在做什么?错误实际发生在哪里?@DmitryB我只是编辑我的问题wi这是一条更详细的错误消息,请您查看我的问题好吗?谢谢!看起来错误在处理响应中-因此此时必须联系服务器。您能否验证服务器代码是否按预期处理,以及服务器响应的返回情况如何?
[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);
}
var jsonResponse = Json( new
                        {
                            success = false,
                            message = "Oops. There was an unexpected error.\n" + ex.ToString()
                        });
jsonResponse.ContentType = "text/html"; // <-- Set content type explicitly.
return jsonResponse;