Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
36
rated 0 times [  41] [ 5]  / answers: 1 / hits: 21690  / 12 Years ago, tue, august 7, 2012, 12:00:00

I am trying to create a grid panel using ExtJS 4.1. It gets its data from the server using an 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 doesn't seem to work.



I get an error message saying that the JSON could not be read. What is more, in Firebug, the sent parameters are not human readable.



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 just fine.



What does the framework do different when using a Proxy?


More From » extjs4.1

 Answers
3

It seems that it is yet another ExtJS issue.



I have found a fix here:



http://www.sencha.com/forum/showthread.php?196194-Ajax-Store-Send-Params-as-JSON-Body


[#83795] Monday, August 6, 2012, 12 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
breonnamayah

Total Points: 574
Total Questions: 115
Total Answers: 96

Location: England
Member since Sun, May 21, 2023
1 Year ago
;