extjs4 store addes get params in the url

坚强是说给别人听的谎言 提交于 2020-01-06 07:52:27

问题


i'm using extjs4 store

In xhtpp calls it shows the http://localhost/home_dir/index.php/questions/content_pie?_dc=1312366604831&hi=&page=1&start=0&limit=25

This is the store code

    var content_type_store = new Ext.data.Store({
    proxy: new Ext.data.HttpProxy({
    url: BASE_URL+'questions/content_pie',
    method:'POST',
    params :{hi:''}

    }),
    reader: new Ext.data.JsonReader({
    root: 'results'
    }, [
    'qtype',
    'qval'
    ])
    });

Even though i set the method as POST its get params appears in url

I'm using codeigniter as my framework. I disabled GET params in CI. Iwnat to send params in post. with ext2 and 3 this code worked fine..

Help me

Thanks


回答1:


method:'POST' in proxy's config won't work. There is no such config option. However there are two ways to make store use POST. The simplier one - just override getMethod function:

var content_type_store = new Ext.data.Store({
  proxy: {
    type: 'ajax',
    url: BASE_URL+'questions/content_pie',
    extraParams :{hi:''},
    // Here Magic comes
    getMethod: function(request){ return 'POST'; }

  },
  reader: {
    type: 'json',
    root: 'results'
  }
});

The second way: override proxy's actionMethods property. If you choose this way your proxy should look like this:

  // ...
  proxy: {
    type: 'ajax',
    url: BASE_URL+'questions/content_pie',
    extraParams :{hi:''},
    // Here Magic comes
    actionMethods: {
      create : 'POST',
      read   : 'POST',
      update : 'POST',
      destroy: 'POST'
    }
  },
  // ...


来源:https://stackoverflow.com/questions/6925081/extjs4-store-addes-get-params-in-the-url

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!