Ext.define('MyApp.view.MyForm', {
extend: 'Ext.form.Panel',
border: 0,
height: 138,
id: 'formPanel1',
margin: 16,
width: 167,
layout: {
type: 'auto'
},
bodyStyle: 'background-color:transparent;',
initComponent: function() {
var me = this;
Ext.applyIf(me, {
items: [
{
xtype: 'textfield',
name: 'f_username',
fieldLabel: '用户名',
labelAlign: 'top'
},
{
xtype: 'textfield',
width: 150,
inputType: 'password',
name: 'f_password',
fieldLabel: '密码',
labelAlign: 'top'
},
{
xtype: 'button',
handler: function(button, event) {
var formPanel1 = Ext.getCmp('formPanel1');
var form1 = formPanel1.getForm();
formPanel1.setLoading(true);
form1.submit({
clientValidation: true,
url: 'Handler.ashx',
params: {
newStatus: 'delivered'
},
success: function(form, action) {
Ext.Msg.alert('成功', '操作完毕', function(){
formPanel1.setLoading(false);
parent.cs_close_defaultWin();
});
},
failure: function(form, action) {
switch (action.failureType) {
case Ext.form.action.Action.CLIENT_INVALID:
Ext.Msg.alert('失败', 'Form fields may not be submitted with invalid values');
break;
case Ext.form.action.Action.CONNECT_FAILURE:
Ext.Msg.alert('失败', 'Ajax communication failed');
break;
case Ext.form.action.Action.SERVER_INVALID:
Ext.Msg.show({
title:'失败',
msg: action.result.msg,
buttons: Ext.Msg.OK,
icon: Ext.Msg.ERROR
});
}
formPanel1.setLoading(false);
}
});
},
margin: '10 0 0 16',
width: 60,
text: '登录'
}
]
});
me.callParent(arguments);
}
});
服务端代码:
context.Response.Write("{ success: true }");
context.Response.Write("{ success: false, msg: '密码不正确' }");