ExtJS: JsonStore not loading at all

I have jsonstore:

jstore = new Ext.data.JsonStore({
    fields: ['id', 'timer', 'name', 'message'],
    root: 'data',
    autoLoad: true,
    proxy: new Ext.data.HttpProxy({
                    url: 'chat.php',
                    method: 'GET',
            }),
            remoteSort: false
});

which does not load data from the url. My php file works correctly, if I find my url in the same URL that is used by the repository, the output is as follows:

{fields: ['id', 'name', 'time', 'message'], 'data': [{id: '5', name: 'stefano', time: '2012-05-21 14:08:58', message: 'mymessage'}]}

which should be a valid json string, right?

The store does not load either autoload or explicit call

jstore.load({params: {mode:'RetrieveNew', id:'-1'}});

Any idea on what can do this? Many thanks!

+3
source share
3 answers

I had the same problem loading the store.

To fix this, I replaced Ext.data.JsonStore with Ext.data.Store. Other parameters are the same. So here is my example of ExtJS autoload storage:

this.datesStore = new Ext.data.Store({
                        id: 'datestore',
                        root: 'dates',
                        autoLoad: true,
                        proxy: new Ext.data.HttpProxy({
                                    url: '/url/to/the/data',
                                    method: 'GET'
                                }),
                        fields: ['date']
                    });
+2
source

You made a typo: autoLoadnotautoLoad

+3
source

:

var stateStore = new Ext.data.JsonStore({
    autoLoad: true,
    root: 'states',
    proxy: new Ext.data.HttpProxy({
        url: 'js/query/states.json',
        method: 'GET'
    }),
    fields: ['stateCode', 'stateName'],
});

stateStore.load();

states.json:

{
  "states": [
      { "stateCode": "01", "stateName": "Johor" },
      { "stateCode": "02", "stateName": "Kedah" },
      { "stateCode": "10", "stateName": "Selangor" }
  ]      
}

, ;)

0

All Articles