1. #1
    Sencha User medley's Avatar
    Join Date
    Apr 2008
    Location
    Luxembourg
    Posts
    128
    Vote Rating
    0
    medley is on a distinguished road

      0  

    Exclamation Answered: Rest proxy - problem with Google Chrome

    Hello,

    I have a store defined like that :

    Code:
    
    
    Code:
    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 :
    Code:
    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

  2. 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.

  3. #2
    Sencha - Tools Team arthurakay's Avatar
    Join Date
    Sep 2008
    Location
    Antioch, IL
    Posts
    1,475
    Vote Rating
    69
    Answers
    85
    arthurakay is a glorious beacon of light arthurakay is a glorious beacon of light arthurakay is a glorious beacon of light arthurakay is a glorious beacon of light arthurakay is a glorious beacon of light

      0  

    Default

    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.

  4. #3
    Sencha Premium Member skirtle's Avatar
    Join Date
    Oct 2010
    Location
    UK
    Posts
    3,786
    Vote Rating
    378
    Answers
    581
    skirtle has a reputation beyond repute skirtle has a reputation beyond repute skirtle has a reputation beyond repute skirtle has a reputation beyond repute skirtle has a reputation beyond repute skirtle has a reputation beyond repute skirtle has a reputation beyond repute skirtle has a reputation beyond repute skirtle has a reputation beyond repute skirtle has a reputation beyond repute skirtle has a reputation beyond repute

      0  

    Default

    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.

  5. #4
    Sencha User medley's Avatar
    Join Date
    Apr 2008
    Location
    Luxembourg
    Posts
    128
    Vote Rating
    0
    medley is on a distinguished road

      0  

    Default


    I changed the reader from xml type to json type.

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


    And now it works with Chrome and Internet Explorer.

    Medley

  6. #5
    Sencha User mberrie's Avatar
    Join Date
    Feb 2011
    Location
    Bangkok, Thailand
    Posts
    506
    Vote Rating
    17
    Answers
    26
    mberrie has a spectacular aura about mberrie has a spectacular aura about

      0  

    Default

    Please mark the question as answered!