View Full Version : Ajax Store - Send Params as JSON Body

17 Apr 2012, 6:05 AM
Is there a way to set up an Ajax Store so that it sends params as JSON in the body of an AJAX request.

I'm looking to mimic the functionality of...

url: '/foo',
jsonData: jsonObject

But as a Ajax Store, such as:

extend: 'Ext.data.Store',
model: 'bar',
proxy: {
type: 'ajax',
url: 'foo.json',
reader: 'json'

Except right now, the store will send the parameters as GET params.

These parameters are going to be pretty complex which is why I'd like to serialize them as JSON, preferably not under a single GET/POST param.

Any ideas?

17 Apr 2012, 6:21 AM
Try moving your proxy from the store to the model.


17 Apr 2012, 6:26 AM
It didn't make a difference. Parameters are added to the querystring instead of serializing the object to the request body.

17 Apr 2012, 10:26 AM
I guess I could just be super hackish and override methods...

17 Apr 2012, 11:14 AM
Okay, here's my hack...

extend: 'Ext.data.Store',


proxy: {
type: 'ajax',


//Add these two properties
actionMethods: {
read: 'POST'

jsonData: true //Custom, used in override

I really didn't want to override such a large method but it was the best entry point.

Ext.override(Ext.data.proxy.Ajax, {

doRequest: function(operation, callback, scope) {
var writer = this.getWriter(),
request = this.buildRequest(operation, callback, scope);

if (operation.allowWrite()) {
request = writer.write(request);

Ext.apply(request, {
headers : this.headers,
timeout : this.timeout,
scope : this,
callback : this.createRequestCallback(request, operation, callback, scope),
method : this.getMethod(request),
disableCaching: false // explicitly set it to false, ServerProxy handles caching

//Added... jsonData is handled already
if(this.jsonData) {
request.jsonData = Ext.encode(request.params);
delete request.params;


return request;

3 Jun 2013, 5:26 AM
I would like to get more info on this one.
I'm using ASP.NET Classic as my server side (I can't switch to MVC4, really!)

This hack works perfect for me, but maybe till now it is build in into ExtJS core classes?
Overrides works for some time, if something will change in core classes this might stop working.

@Scott any news on this? I know that ASP.NET Classic is an old technology, but adding one parameter to Ajax proxy can't be so hard, especially @strickjb posted nice solution.

31 Jul 2014, 11:35 PM
Hi Can you provide, any example to post Params as JSON Body to store.. because I am getting error " Ext.Ajax.request(request);" as null request..

22 Jul 2015, 12:47 AM
Okay, here's my hack...

Thank you! Can you explain where in my code I would be able to set the JSON data dynamically?