Extjs6设置Store、Ajax、form的请求方式(GET、POST)

Extjs6 设置Store、Ajax、form的请求方式(GET、POST)

Ajax请求和Form的submit方法设置请求方式和原来一样,使用method : 'POST'设置

 
  1. // 表单提交  
  2. winForm.getForm().submit({  
  3.     waitTitle : '提示',// 标题  
  4.     waitMsg : '正在提交数据请稍后...',// 提示信息  
  5.     url : '../../../dayReportController/add.do',  
  6.     method : 'POST',  
  7.     params : { // 此处可以添加额外参数  
  8.         extraParems : 'extraParems'  
  9.     },  
  10.     success : function(form, action) {  
  11.         /*  
  12.          * 第二种方法获取返回值  
  13.         var success = action.result.success;  
  14.         alert(success);  
  15.         */  
  16.           
  17.         var respText = Ext.util.JSON.decode(action.response.responseText)  
  18.         if (respText.success == true) {  
  19.             Ext.Msg.alert('消息', '保存成功!');  
  20.             Ext.getCmp('win').close();// 添加成功后关闭窗口  
  21.             Ext.getCmp('menuGrid').getStore().reload(); // 添加成功后重新刷新表格  
  22.         } else {  
  23.             Ext.Msg.alert('消息', respText.msg);  
  24.         }  
  25.     },  
  26.     failure : function(form, action) {  
  27.         Ext.Msg.alert("消息", "操作失败!");  
  28.     }  
  29. });  

 

 
  1. Ext.Ajax.request({  
  2.     method : 'POST',  
  3.     url : '../../../dayReportController/deleteMenu.do',  
  4.     params : {  
  5.         'id' : id // 要删除记录的id  
  6.     },  
  7.     success : function(response, config) {  
  8.         /*  
  9.         // 后台:out.print(1);  
  10.         var result = response.responseText;  
  11.         if (parseInt(result) == 1) {  
  12.             Ext.getCmp('menuGrid').getStore().reload();  
  13.             Ext.Msg.alert("提示", '删除成功!');  
  14.         } else {  
  15.             Ext.Msg.alert('提示', '删除失败!');  
  16.         }  
  17.         */  
  18.           
  19.         // 后台:out.print({success : true});  
  20.         var json = Ext.util.JSON.decode(response.responseText);  
  21.         if (json.success == true) {  
  22.             Ext.getCmp('menuGrid').getStore().reload();  
  23.             Ext.Msg.alert("提示", '删除成功!');  
  24.         } else {  
  25.             Ext.Msg.alert('提示', '删除失败!');  
  26.         }  
  27.     },  
  28.     failure : function() {  
  29.         Ext.Msg.alert('提示', '删除失败!');  
  30.     }  
  31. });  

 

Store设置请求方式使用   actionMethods : {

                                                                    read : 'POST'

                                                                  }

 

 
  1.    var store = Ext.create('Ext.data.Store', {  
  2.     // autoLoad : true,  
  3.     pageSize : main.gridPageSize,  
  4.     fields : ['id', 'text', 'description', 'url', 'leaf'],  
  5.     proxy : new Ext.data.HttpProxy({  
  6.         type : 'ajax',  
  7.         url : '../../../dayReportController/test.do',  
  8.         actionMethods : {  
  9.             read : 'POST' // Store设置请求的方法,与Ajax请求有区别  
  10.         },  
  11.         reader : new Ext.data.JsonReader({  
  12.             type : 'json',  
  13.             rootProperty : 'data',// 数据(不配置的话无法接收数据),返回的key为data  
  14.             totalProperty : 'totalRecord'// 记录数(不配置的话无法翻页),返回的key为totalRecord  
  15.         })  
  16.     })  
  17. });  

原文链接:https://blog.csdn.net/diweikang/article/details/48344523

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值