转自:http://weizhilizhiwei.iteye.com/blog/1671431
之前总是封不起Extjs中form.submit()提交与Ext.Ajax.request()的区别,现在仍是分不清,但是知道怎么用不会出错了。
方案1:
java action中的代码
- Stringdatastring="total:"+rehpage.getCount()+",root:[";
- if(rehpage!=null){
- datastring+=buildJsonByPage(rehpage);
- }
- datastring=datastring+"]";
- StringBufferbuff=newStringBuffer("{success:true,mes:{");
- buff.append(datastring);
- buff.append("}}");
-
- System.out.println("datastringis:"+buff.toString());
- request.setAttribute("responseText",buff.toString().replaceAll("rn",
- "").replaceAll("n",""));
- returnSUCCESS;
对用的Extjs中的代码为:
Ext.Ajax.request({
url:"./rehearsal/queryTableData.action",250); line-height:18px"> params:{
search_place:rehearsal_place,250); line-height:18px"> search_time:dt
.format('Y-m-d'),250); line-height:18px"> search_valuation:null,250); line-height:18px"> search_subject:search_subject
},250); line-height:18px"> waitMsg:'正在提交数据',250); line-height:18px"> waitTitle:'提示',250); line-height:18px"> method:"POST",250); line-height:18px"> success:function(response){
varrespText=Ext.util.JSON
.decode(response.responseText);
if(respText.success){
szcdc_rehearsal_one_grid
.getStore()
.loadData(respText.mes);
failure:function(response){
Ext.Msg.alert('提示',250); line-height:18px"> "操作失败:输入非法字符!!!");
});
}
方案2:
java action中的代码是:
);
buff.append("}");
对应的Extjs代码为:
search_form.submit({
baseParams:{
search_time:search_time,250); line-height:18px"> search_valuation:search_valuation,250); line-height:18px"> success:function(form,action){
varresult=Ext.util.JSON
.decode(action.response.responseText);
//把数据放到结果里面
szcdc_rehearsal_one_grid.getStore()
.loadData(result);
failure:function(form,"操作失败:输入非法字符!!!");
});
将form中的字段转成json格式:form.getForm().getFieldValues(); (编辑:李大同)
【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!
|