我用别的组件都能回调到success里面,但使用fileupload组建却回调不到success里面,老是提示有文件下载。请问是怎么回事?
var fp = new Ext.FormPanel({
       /// renderTo: 'fi-form',
        fileUpload: true,
        width: 500,
        frame: true,
        title: 'File Upload Form',
        autoHeight: true,
        bodyStyle: 'padding: 10px 10px 0 10px;',
        labelWidth: 50,
        defaults: {
            anchor: '95%',
            allowBlank: false,
            msgTarget: 'side'
        },
        items: [{
            xtype: 'textfield',
            fieldLabel: 'Name'
        },{
            xtype: 'fileuploadfield',
            id: 'form-file',
            emptyText: 'Select an image',
            fieldLabel: 'Photo',
            name: 'contents',
            buttonText: '',
            buttonCfg: {
                iconCls: 'upload-icon'
            }
        }],
        buttons: [{
            text: 'Save',
            handler: function(){
                if(fp.getForm().isValid()){
                        fp.getForm().submit({
                            url: 'deleteWorklogdiy.action',
                           waitMsg: 'Uploading your photo...',
                            timeout : 2000,
                            success : function(fp, action) {
                                            pic_out.hidden();
                                                                         Ext.Msg.alert("信息提示", "OK");
                                                                },
                                                                // 提交失败的回调函数
                                                failure : function() {
                                                                        pic_out.hidden();
                                                                        Ext.Msg.alert('错误', '服务器出现错误请稍后再试!');
                                                                }
                        });
                }
               
               
            }
        },{
            text: 'Reset',
            handler: function(){
                fp.getForm().reset();
            }
        }]
    });var pic_out = new Ext.Window({
                                title : 'pic',
                                width : 600,
                                height : 300,
                                closeAction : 'hide',
                                constrain : true,
                                modal : true,
                                items : [fp]
                        });
function uploadpicfunction(){
pic_out.show();} 

解决方案 »

  1.   

    补充说明:返回的格式是{success:true,failure:false}  后台配了json格式的数据返回
      

  2.   

    form提交后,要返回success方法,必须返回json格式{success: true}, 看看你json是否包含了。
    老是提示有文件下载这句话没在你代码看到,难道是浏览器的?
      

  3.   

    一般我都是返回的是{success:true,msg:'XXXX'}
    success为true时回调到success里面
    success为false时回调到failure里面
    是不是你同时返回了{success:true,failure:false}起了冲突?
    这个估计要看看form.panel是怎么封装的了~~
      

  4.   

    ext中对json数据的处理解析:http://blog.csdn.net/xieshengjun2009/article/details/5959687