Peter
Peter

Reputation: 914

ExtJs, how to send JSON on store.load() using POST method

I need to send JSON object during read operation on store. Headers and method are set correctly.

var proxyDefinition = {
    type : 'rest',
    api : {
        read : '/some/url'
    },
    actionMethods : {
        create  : 'POST',
        read    : 'POST',
        update  : 'PUT',
        destroy : 'DELETE'
    },
    reader : {
        type : 'json'
    }        
};

var store = Ext.create('Ext.data.Store', {
    proxy : proxyDefinition,
    model : 'SomeModel'
});

// this needs to send JSON
store.load({
    params : {
        filter: [] // some filtering rules
    }
});

Problem is that POST body is sent as url encoded query string, not JSON object with property "filter".

ExtJs version 4.2.2

Upvotes: 3

Views: 11210

Answers (1)

Saki
Saki

Reputation: 5856

It is likely that you are looking for proxy config option paramsAsJson:true

Upvotes: 6

Related Questions