PDA

View Full Version : Rest proxy - problem with Google Chrome



medley
23 Aug 2011, 6:23 AM
Hello,

I have a store defined like that :




Ext.define('EPplatosRegistry.store.Services', {
extend : 'Ext.data.Store',
model: 'EPplatosRegistry.model.Service',
storeId: 'servicesStore',
autoLoad: true,
proxy: {
type: 'rest',
url : 'http://localhost:8080/epplatos-registry-services/services/service',
appendId: true,
reader: {
type: 'xml',
root: 'services',
record : 'service'
},
writer : {
type: 'json',
root: 'service',
writeAllFields: true
}
}
....


In Firefox, the grid is well displayed. However, with Chrome, I get this message :


Uncaught TypeError: Cannot read property 'records' of undefined


In response header, the content-type is application/xml with Firefox . OK.
But with Chrome, the content-type is application/json. Not OK. And I don't know why.

Thanks for help
Medley

arthurakay
23 Aug 2011, 1:53 PM
So you're reading XML, but writing JSON? Sounds weird to me...

Anyways, you're describing a problem that stems from the GET operation (loading your data into the Reader). What does the actual response from the server look like? Also, what's the content-type set by the server?

If I had to guess, I'd say it sounds like the server is not correctly defining the response content-type so the browser is attempting to assign one.

skirtle
23 Aug 2011, 9:59 PM
Chrome often 'lies' about content-types. If you haven't got one set on the server it will guess and then show that guess in the Network section.

If you go to the Network section and click on the name of the file on the left-hand side it should give you more information, including the response headers. I believe you can trust the value shown there for content-type.

medley
24 Aug 2011, 6:21 AM
I changed the reader from xml type to json type.


reader: {
type: 'json',
root: 'services'
}


And now it works with Chrome and Internet Explorer.

Medley

mberrie
26 Aug 2011, 4:33 AM
Please mark the question as answered!