ExtJS Ajax POST vs Proxy POST

I am trying to create a grid panel using ExtJS 4.1. It receives its data from the server using the AJAX proxy:

var store = Ext.create('Ext.data.Store', { model: 'myModel', pageSize: pageSize, proxy: { type: 'ajax', url: "../search", actionMethods: { create: "POST", read: "POST", update: "POST", destroy: "POST" }, headers: { 'Content-Type': 'application/json' }, limitParam: false, startParam: false, pageParam: false, extraParams: JSON.stringify({ rows: pageSize, role: "Admin", index: myIndex, question: searchPhrase }), reader: { type: 'json', root: 'results.results', totalProperty: 'numFound', model: 'myModel' } } }); store.loadPage(1); 

but it does not work.

I get an error message stating that JSON could not be read. Moreover, in Firebug the parameters sent are not readable by humans.

When I try to make an Ajax call with the same parameters, everything seems to be OK:

 Ext.Ajax.request({ url:"../search", method: "POST", params: JSON.stringify({ rows: pageSize, role: "Admin", index: myIndex, question: searchPhrase }), success: function(){ console.log("ok"); }, failure: function(response, opts){ console.log("failed"); }, headers: { 'Content-Type': 'application/json' } }); 

Even in Firebug, every parameter in the request looks simple.

What makes the framework different when using a proxy?

+4
source share
1 answer
0
source

All Articles