也来问个extjs简单的提交
zsrui 2011-03-31 09:19:27 点击“submit”按钮,显示“正在提交”进度条,一闪而过,既没有成功提示,也没有失败提示,表单填写的内容都保留。怎么success和failure都没执行呢?save.html的内容是"哇哈哈",几个中文字,也应该没问题。
<script type="text/javascript">
Ext.onReady(function(){
Ext.QuickTips.init();
// turn on validation errors beside the field globally
Ext.form.Field.prototype.msgTarget = 'side';
var bd = Ext.getBody();
bd.createChild({tag: 'h2', html: '<a>Form 1 - Very Simple</a>'});
var simple = new Ext.FormPanel({
labelWidth: 75, // label settings here cascade unless overridden
frame:true,
title: '个人信息',
bodyStyle:'padding:5px 5px 0',
width: 350,
defaults: {width: 230},
defaultType: 'textfield',
items: [{
fieldLabel: 'First Name',
name: 'first',
allowBlank:false
},{
fieldLabel: 'Last Name',
name: 'last'
},{
fieldLabel: 'Company',
name: 'company'
}, {
fieldLabel: 'Email',
name: 'email',
vtype:'email'
}, new Ext.form.TimeField({
fieldLabel: 'Time',
name: 'time',
minValue: '8:00am',
maxValue: '6:00pm'
})
],
buttons: [{
text: 'Save',
type: 'submit',
handler: function(){
if(simple.getForm().isValid()){
//alert('222222');
simple.getForm().submit({
url: 'save.htm',
waitMsg: '正在提交...',
success: function(simple, resp){
Ext.Msg.alert("提示","保存失败:" + resp.result.message);
},
failure : function(simple, action) {
Ext.Msg.alert("提示","保存失败:" + action.result.errors.info);
}
})
}
}
},{
text: 'Cancel',
handler: function() {
simple.form.reset();
}
}]
});
simple.render(document.body);
})
</script>