Extjs4中表單登錄功能,實現登錄成功跳轉頁面

Ext.onReady(function(){
	Ext.QuickTips.init();
	Ext.create('Ext.form.Panel',{
		title:'form2',
		width:300,
		height:200,
		frame:true,
		renderTo:'formDemo',
		defaultType:'textfield',
		defaults:{
			allowBlank:false,
			labelWidth:60,
			width:240,
			msgTarget:'side'
			
		},
		items:[{
			name:'userName',
			fieldLabel:'Name'
		},
		{
			name:'password',
			fieldLabel:'Pass'
		}],
		buttons:[{
			text:'提交',handler:function(){
				var basic=this.up('form').getForm();
				basic.submit({
					url:'/Extjs4/formAction!getForm.action',
				    method:'POST',
				    success:function(form,action){
				    	location.href="/Extjs4/demo.html";
				    },
				    failure:function(form,action){
				    	var data=action.response.responseText;
				    	var json = eval("("+data+")");
				    	Ext.Msg.alert('提示',json.message);
				    }
				});

			}
		},
		{text:'重置',handler:function(){
			this.up('form').getForm().reset();
			}
		}
		]
	});
});

 

發佈留言