extjs4 store addes get params in the url

2019-09-08 16:44发布

问题:

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'
    }
  },
  // ...