zoukankan      html  css  js  c++  java
  • 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

  • 相关阅读:
    vuex 简单理解
    es2015(es6)学习总结
    工作资源知识点总结收集
    margin-top使用需要注意的地方
    关于用display:table让元素居中的小结
    display:table-cell
    margin:0 auto;不居中
    css选择器总结
    css 选择器优先级
    给行内元素加上绝对定位之后,元素属性的变化
  • 原文地址:https://www.cnblogs.com/1175429393wljblog/p/8807422.html
Copyright © 2011-2022 走看看