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

    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 - Services Team arthurakay's Avatar
    Join Date
    Sep 2008
    Location
    Antioch, IL
    Posts
    1,364
    Answers
    60
    Vote Rating
    33
    arthurakay is a jewel in the rough arthurakay is a jewel in the rough arthurakay is a jewel in the rough

      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.
    Arthur Kay
    Developer Relations Manager, Sencha Inc.

    Twitter | Sencha Chicago User Group

  4. #3
    Sencha Premium Member skirtle's Avatar
    Join Date
    Oct 2010
    Location
    UK
    Posts
    3,596
    Answers
    542
    Vote Rating
    324
    skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future

      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
    Answers
    26
    Vote Rating
    14
    mberrie will become famous soon enough mberrie will become famous soon enough

      0  

    Default


    Please mark the question as answered!