PDA

View Full Version : What's wrong with this?



ward
28 Jun 2007, 1:57 PM
I am trying to load JSON data from a PHP script, and I can see the HTTP request and result through firebug, but it is not being loaded into my data store. From my main code, I create a new myDataStore, and call myDataStore.Init(). Am I doing something wrong here?

JSON Response from PHP


{

'results': 5,
'rows':
[
{'id':0, 'name': 'Description', 'type': 'longtext', 'value': 'test'}
]
};


Datastore wrapper class:


function myDataStore()
{
this.RecordDef = null
this.Store = null;

// Record Definition
this.RecordDef = Ext.data.Record.create
(
[
{name: 'name'},
{name: 'type'},
{name: 'value'}
]
);

// DataStore
this.Store = new Ext.data.Store
(
{
proxy: new Ext.data.HttpProxy
(
{
url: 'bridge/json.php'
}
),
reader: new Ext.data.JsonReader
(
{
totalProperty: 'results',
root: 'rows',
id: 'id'
},
this.RecordDef
)
}
);

// Init
this.Init = function()
{
this.Store.on('load',function(){alert('here')});
this.Store.load();

}
}