warlord0
13 Jul 2007, 8:45 AM
Ok, I'm missing something really fundamental I think. I just can't seem to get the access to data working right when you want to use it directly.
I'm using a bit of authentication using group memberships. This uses Ajax to query the server to see what groups a user is a member of.
function getMembership(userid) {
dsMembership = new Ext.data.Store({
proxy: new Ext.data.HttpProxy({
url: 'jsonAuth.php' //?query=getmembership&userid='+userid
}),
reader: new Ext.data.JsonReader({
root: 'results',
totalProperty: 'total'
}, [
{success: 'success'},
{groups: 'groups'}
])
});
dsMembership.on('load', function() {
alert(dsMembership.getAt(0).results.success); // Response is "undefined" getCount yeilds 0 (Zero)
});
dsMembership.load({params:{query:'getmembership', userid:userid}});
}
Here is the json that get returned from my php script (as shown in firebug)
({"total":"2","results":{"success":true,"groups":["1","3"]}})
What I'm after is the array "groups" from the json data the rest is just filler to help identify that something was returned and how many.
Is my record definition correct to match the json data? Can anyone point out the error of my ways?
I'm using a bit of authentication using group memberships. This uses Ajax to query the server to see what groups a user is a member of.
function getMembership(userid) {
dsMembership = new Ext.data.Store({
proxy: new Ext.data.HttpProxy({
url: 'jsonAuth.php' //?query=getmembership&userid='+userid
}),
reader: new Ext.data.JsonReader({
root: 'results',
totalProperty: 'total'
}, [
{success: 'success'},
{groups: 'groups'}
])
});
dsMembership.on('load', function() {
alert(dsMembership.getAt(0).results.success); // Response is "undefined" getCount yeilds 0 (Zero)
});
dsMembership.load({params:{query:'getmembership', userid:userid}});
}
Here is the json that get returned from my php script (as shown in firebug)
({"total":"2","results":{"success":true,"groups":["1","3"]}})
What I'm after is the array "groups" from the json data the rest is just filler to help identify that something was returned and how many.
Is my record definition correct to match the json data? Can anyone point out the error of my ways?