View Full Version : use the POST method for read, create, update, destroy actions of a Ext.data.JsonStore

27 Jan 2011, 1:23 AM
I use a Ext.data.JsonStore this way :

var remoteGridJsonStore = new Ext.data.JsonStore({
proxy: remoteGridProxy,
baseParams: { pageId: id, subjectId: subjectId, gridNum: gridNbr, sptNbr: (sptNbr+1), screenSequence: screenSequence },

At the beginning remoteGridProxy was a ScriptTagProxy :

var remoteGridProxy = new Ext.data.ScriptTagProxy({
read: { url : '../secure/getSubjectDataGrid.htm', method: 'GET' },
create: { url : '../secure/createSubjectDataGrid.htm', method: 'POST' },
update: { url : '../secure/updateSubjectDataGrid.htm', method: 'POST' },
destroy: { url : '../secure/deleteSubjectDataGrid.htm', method: 'POST' }

Unfortunately the method used for the 4 actions is GET whatever method is specified and I had some problems because the length of the request was limited so I have to use the POST method

I tried this :

var remoteGridProxy = new Ext.data.HttpProxy({
method: 'POST',
read: '../secure/getSubjectDataGrid.htm',
create: '../secure/createSubjectDataGrid.htm',
update: '../secure/updateSubjectDataGrid.htm',
destroy: '../secure/deleteSubjectDataGrid.htm'

But without success : the browser act unexpectively : there must be a javascript error which isn't explained

Could anyone tell me if
1) I can use Ext.data.HttpProxy to send the requests with POST method
2) where is the syntax error

Thank you in advance for your answers

28 Jan 2011, 3:32 AM
Yes you can use POST with HTTPProxy. have you tried to debug with Firebug and check if you have any JS errors?

28 Jan 2011, 3:42 AM
read: { url : '../secure/getSubjectDataGrid.htm', method: 'GET' },

first try to change this "read" to some POST. GET serves only
to get simple url with simple params (id, some short values, etc), not for big grid data.

than, what runs correctly ? read ? create ? update ? destroy ? or none of them ?

28 Jan 2011, 11:07 AM
I am trying this :

var remoteGridProxy = new Ext.data.HttpProxy({
read: { url: '../secure/getSubjectDataGrid.htm', method: 'GET' },
create: { url: '../secure/createSubjectDataGrid.htm', method: 'POST' },
update: { url: '../secure/updateSubjectDataGrid.htm', method: 'POST' },
destroy: { url: '../secure/deleteSubjectDataGrid.htm', method: 'POST' }
listeners: {
exception: function(dataProxy, type, action, options, response, arg) {
console.log('PROXY ERROR type='+type);
console.log('status='+response.status+' statusText='+response.statusText);
console.log(' arg=');


The exception handler is fired for my request

I obtain the following results :

and for arg
SyntaxError: missing ) in parenthetical { message="missing ) in parenthetical", fileName="https://localhost:8443/enable/ext/ext-all.js", more...}
in detail it is
fileName= "https://localhost:8443/enable/ext/ext-all.js"
message="missing ) in parenthetical"
stack="eval("(null({\"success\":true,\"message\":\"Loaded data\",\"records\":[],\"totalCount\":0});)")@:0 ("null({\"success\":true,\"message\":\"Loaded data\",\"records\":[],\"totalCount\":0});")@https://localhost:8443/enable/ext/ext-all.js:7 ("null({\"success\":true,\"message\":\"Loaded data\",\"records\":[],\"totalCount\":0});")@https://localhost:8443/enable/ext/ext-all.js:7 ([object Object])@https://localhost:8443/enable/ext/ext-all.js:7 ("read",[object Object],[object Object])@https://localhost:8443/enable/ext/ext-all.js:7 ([object Object],true,[object Object])@https://localhost:8443/enable/ext/ext-all.js:7 ([object Object])@https://localhost:8443/enable/ext/ext-all.js:7 f([object Object],[object Object])@https://localhost:8443/enable/ext/adapter/ext/ext-base.js:7 (451)@https://localhost:8443/enable/ext/adapter/ext/ext-base.js:7

The response of my request according to firebug is :

null({"success":true,"message":"Loaded data","records":[],"totalCount":0});
where null is the callback parameter

Is there a problem with ext-all.js or is it just the response that is not correct ? I noticed that in my editor this file (ext-all.js) is underlined with red

28 Jan 2011, 11:29 AM
And "POST" don't work on HttpProxy or what ? Do you tried ?

28 Jan 2011, 2:58 PM
What are you trying to do; make a goofy thread? What is this null in your xhr response? That's invalid. What are you talking about POST for? Seems like your defining the methods for your api, seems like everything about your ajax process is valid except your response. So, yeah, an invalid response...

28 Jan 2011, 3:22 PM
hey flamant ! finally is there something which works on your grid ? your json (passed by jsonlint) is ok.
try to simplify it at maximum, and add stuff step by step... Verify each one before going forward...

28 Jan 2011, 11:23 PM
effectively the null callback parameter was invalid.
I succeeded in using POST with httpProxy

28 Jan 2011, 11:26 PM
cool :-) finally !