ext的ajax提交

阅读更多
var editForm=Ext.getCmp('formId').form.getValues();// formId为表单id
var beanName = 'bean.';
var bean = {};
for (var i in editForm) {
   bean[beanName + i]=editForm[i];
}
var infoArray = [];
var infoStore=Ext.getCmp('list').getStore();// list为一表格id
for (var i = 0; i < infoStore.getCount(); i++) {
  infoRecord = infoStore.getAt(i);
  if(infoRecord.dirty){
    infoArray.push(infoRecord.data);
  }
}
bean[grid] = Ext.util.JSON.encode(infoArray);
Ext.Ajax.request({
   url : saveUrl,
   method:'post',
   params : bean,
   success : function(form, action) {
      Ext.Msg.alert('提示', '操作成功');
   },
   failure : function(form, action) {
      //Ext.Msg.alert('警告', '用户名或密码错误!');
   }
})

注意:servlet中所加的属性为bean,grid,其中bean为一对象,grid为一字符串

你可能感兴趣的:(EXT,Ajax,Bean,json,Servlet)