Ext 表单异步提交

js部分:
//新添数据库表单
var form_Upload = function(){
    return new Ext.form.FormPanel({
        id : 'form_Upload',
        fileUpload: true,
        frame: true,
        title: '上传数据库',
        url: 'databaseControl.ashx',
        bodyStyle: 'padding: 20px 10px 0 10px;',
        labelWidth: 80,
        defaults: {
            anchor: '95%',
            allowBlank: false,
            msgTarget: 'side'
        },
        items: [{
            xtype: 'textfield',
            fieldLabel: '数据库名称',
            name: 'dbName'
        },{
            xtype: 'fileuploadfield',
            id: 'form-file',
            emptyText: '选择本地sqlite3数据库文件',
            fieldLabel: '本地数据库',
            name: 'sqlite-path',
            buttonText: '',
            buttonCfg: {
                iconCls: 'upload-icon'
            }
        }],
        buttons: [{
            text: '确定',
            handler:function(){
                var form = Ext.getCmp('form_Upload').getForm();   
                if(form.isValid()){             
                    form.submit({
                        params:{
                            action: 'upload'
                        },
                        success:function(form,action){
                            //Ext.Msg.alert('信息',action.result.msg);
                            if(action.result.id == 0)
                            {//
                                Ext.Msg.alert("提示","数据库名称:"+action.result.name+" 重复");
                            }else
                            {
                                addDatabaseNode(action.result.id,action.result.name);
                                closeExtwin('win_dbName');
                            }
                        },
                        failure:function(){
                            Ext.Msg.alert('错误','操作失败!');
                        }
                    }); 
                }        
            }  
        },{
            text: '重置',
            handler:function(){ resetExtform('form_Upload');}                            
        },{
            text: '取消',
            handler:function(){closeExtwin('win_dbName');}                            
        }]
    });
}
//重置表单
function resetExtform(id)
{
    var form = Ext.getCmp(id);
    if(form)
        form.getForm().reset();
}



后台代码:
处理后返回:
context.Response.Write("{success:true,msg:'成功',id:'" + id.ToString() + "',name:'" + dbName + "'}"); //反回信息


你可能感兴趣的:(数据库,function,sqlite,upload,ext,action)