formPanel.form.submit({ waitTitle : "请稍候", waitMsg : "正在提交表单数据,请稍候.......", url : updateurl, method : "POST", success : function(form, action) { Ext.MessageBox.alert('提交失败', action.result.msg); //Ext.MessageBox.alert('提示信息', '数据已经成功提交!'); }, failure : function(form, action) { Ext.MessageBox.alert('提交失败', action.result.errors); //Ext.MessageBox.alert('提示信息', '表单提交失败!'); } });
servlet端返回数据的格式:
success:
"{success:true, msg:'successed!'}"
failure:
"{success:false, errors:'failured!'}"
或者
"{success:false, errors:\"failured!\"}"
或者
"{success:false, errors:{info:'failured!'}}",此时web端应写为Ext.MessageBox.alert('提交失败', action.result.errors.info);
注意function(form, action){}参数的位置不要写反了,要不会得到action.result.errors不是对象或未定义之类的错误