也来问个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>
...全文
58 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
zsrui 2011-03-31
  • 打赏
  • 举报
回复
返回结果要符合json格式的
{ success: true, errors:{info: '错误了'}, message:'成功啦啦啦' }
zsrui 2011-03-31
  • 打赏
  • 举报
回复
纯测试。


明白了,应该写明reader格式。
dataminer_2007 2011-03-31
  • 打赏
  • 举报
回复
你为什么不提交到后台?

提交的请求返回的格式不正确当然会进入 failure 了
zsrui 2011-03-31
  • 打赏
  • 举报
回复
按钮代码改成这样,能显示“shibai”提示框,但为什么失败呢?save.html是有内容的呀,而且也没显示action.result.errors.info内容????????????


simple.getForm().submit({
url: 'save.html',
waitMsg: '正在提交...',
success: function(simple, resp){
alert("chenggong");
Ext.Msg.alert("提示","保存失败:" + resp.result.message);
},
failure : function(simple, action) {
alert("shibai");
Ext.Msg.alert("提示","保存失败:" + action.result.errors.info);
}
})

52,797

社区成员

发帖
与我相关
我的任务
社区描述
Web 开发 Ajax
社区管理员
  • Ajax
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧