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