1
votes

Trying to use sencha proxy - but no luck - I get the error - Uncaught SyntaxError: Unexpected token :

    Ext.define('The.store.Login', {
        extend: 'Ext.data.Store',
        config: {
            model: 'The.model.Login',
            proxy: {
                type: 'jsonp',
                url: 'THE_URL_THAT_RETURNS_JSON',
                headers: {
                        'Access-Control-Allow-Origin': '*',
                        'Content-Type': 'application/json',
                        'Authorization': 'THE_AUTH_BASE64_ENCODED_KEY'
                },
                reader: {
                    type: 'json',
                    rootProperty: 'd'
                }
            },
            autoLoad: false

        }
    });

This is my sencha code

And the json that comes back is -

    {
    "d" : [
    {
    "__metadata": {
    "uri": "States", "type": "State"
    }, "CountryCodeString": "USA", "StateCode": "AA", "ActiveFlag": true, "StateDescription": "Americas"
    }, {
    "__metadata": {
    "uri": "States", "type": "State"
    }, "CountryCodeString": "CAN", "StateCode": "AB", "ActiveFlag": true, "StateDescription": "Alberta"
    }, {
    "__metadata": {
    "uri": "States", "type": "State"
    }, "CountryCodeString": "BRA", "StateCode": "AC", "ActiveFlag": true, "StateDescription": "AC"
    }, {
    "__metadata": {
    "uri": "States", "type": "State"
    }, "CountryCodeString": "AUS", "StateCode": "ACT", "ActiveFlag": true, "StateDescription": "ACT"
    }, { .....
2
Just a guess, but did you verify that the json data coming back matches the model used by the store? - forgivenson
Yeah Model is good - Just that when I get the json I get the error. - vivianaranha

2 Answers

1
votes

If you are using JsonP then a callback is required from the server. I.E.

callback4587({"json":"here"})

The callback will be sent as a parameter automatically by ExtJS framework and the server will need to respond with the same callback.

If you use Ajax request the callback will not be required. However, you will need to setup cross origin access in server configuration.

1
votes

Change your proxy type to ajax.

Jsonp is required for retrieving data from a server in a different domain.