1

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 Answers 2

2

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.

Sign up to request clarification or add additional context in comments.

Comments

0

you can do:

ids[0].id

or skip the "ids" variable and do:

json[0].client

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.