tags:

views:

39

answers:

2

I have a function

$.post('php/client.login.php', {username:username, password:password}, function(json){

                    var ids = json;
                    alert(json.id);

}, 'json');

Which returns undefined, the json data i am trying to read is this

[{"id":"8","client":"sam","email":"sam","username":"sam","password":"sam","case_ids":"61,63,54"}]

it's parsing fine but i cannot read the data, any suggestions?

+2  A: 

If your data is as posted, it should be

json[0].id

The data is wrapped in square brackets, making it an array with a single element.

Kobi
A: 

you can do:

ids[0].id

or skip the "ids" variable and do:

json[0].client
Sam3k