我在一个window中放个formPanel 当我点提交后,后台能接收到表单数据,但是就是一直在读进度条,也没有返回success对话框。
[code="java"]
awin = new Ext.Window({
title: 'Add Requirment',
layout:'fit',
width:500,
height:300,
modal:true,
items: addButtonFP=new Ext.FormPanel({
labelAlign: 'left',
baseCls: 'x-plain',
labelWidth:120,
buttonAlign:'center',
bodyStyle:'padding:5px',
defaultType: 'textfield',
items: [{
fieldLabel: 'Requirement Name',
name: 'name',
anchor:'90%', // anchor width by percentage
allowBlank:false,
blankText:"not null"
},{ xtype: 'combo',
fieldLabel: 'Priority',
tpl: '<tpl for="."><div ext:qtip="{nick}" class="x-combo-list-item">{state}</div></tpl>',
store: PriorityCombo,
displayField:'state',
emptyText:'Please choose...',
selectOnFocus:true,
triggerAction: 'all',
mode: 'local',
name: 'priority'
// anchor: '100%'
},{
xtype: 'textarea',
fieldLabel: 'Description',
name: 'desc',
autocomplete:'on',
anchor: '100% -53'
}]
}),
buttons: [{
text:'Submit',
handler: function(){
var form=addButtonFP.getForm();
if(form.isValid()){
form.submit(
{url:'reHandler.htm',
waitMsg:'Saving data',//一直都在读这个进度条
baseParams:{method:'addRes'}, //如果这行参数去掉就不会读进度条了
method:'post',
success:function(form,action){
Ext.Msg.alert('Success',form.responseText);
this.refresh();
},
failure: function(){
Ext.Msg.alert('Failure','Please check');
}
}
);
}
}
},{
text: 'Cancel',
handler: function(){
awin.hide();
}
}]
});
awin.show(this);
[/code]
我用的是spring 的MVC ,url 是要带个method的参数才能找到action的。这个该如何是好啊 有人遇到我这样的问题吗 还是我那里写错了?
[b]问题补充:[/b]
这个baseParams:{method:'addRes'}, 只是传个参数 参数名字可以变的,spring那里可以设置的
我 baseParams:{m:'addRes'},也是一样的 只想传个参数,现在的问题是 到达后台后返回前台时 一直在读进度条
[b]问题补充:[/b]
这里*.htm 也是在spring 那里设置的 你可以把它看作 *.do就可以了
我的后台是
[code="java"]
res.setContentType("text/html;charset=utf-8");
req.setCharacterEncoding("UTF-8");
System.out.println("entering--------------------");
System.out.println(req.getParameter("name")+"----------------------");
System.out.println(req.getParameter("priority")+"----------------------");
System.out.println(req.getParameter("desc")+"----------------------");
PrintWriter out = res.getWriter();
out.print("Success!");
out.flush();
out.close();
return new ModelAndView(main); //我这里写return null 都一样的效果
[/code]
这些都能打印出来 就是传到前台一直在读进度条
[b]问题补充:[/b]
debug 过了
missing ) in parenthetical
(Success!) ext-all.js (line 7)
难道是ext的bug?
[b]问题补充:[/b]
上图勒 不太会debug 是这样吗
[b]问题补充:[/b]
这个是我看 Rowen ,后台写的 out.print("success :true").
那该如何写呢 请指教
out.print("{success :true}");
需要去补下json的知识
[quote]baseParams:{method:'addRes'}, //如果这行参数去掉就不会读进度条了 [/quote]
这行你用来干什么...
下面method:post了
你又method 'addRes'?
url:'reHandler.htm',?这里为什么是htm?
你后台处理完有没有success :true 返回给前台
1.先用firebug看下ajax请求返回了没
2.再看看是不是解析错误.
{
"success":true, // note this is Boolean, not string
"msg":"Consignment updated"
}
用firebug看下ajax的response,贴出来
[quote]out.print("Success!");[/quote]
是这样写吗?
我记得好像不是..
偶本本不在,不能查代码:只能告诉你..大概 out.print("success :true")..
[size=large][b]用firebug看下ajax的response,贴出来[/b][/size]
点开它..然后看response那页
[img]http://www.iteye.com/upload/attachment/141156/32ca2a17-e0aa-3c0f-961c-d2e2c76e9d98-thumb.png?1251692932[/img]
不是标准的json格式
{success:true}