if your array has multiple items:
Main Topics
Browse All TopicsHow do I access the encoded JSON return? Here is my formatted JSON result:
[{"id":"24695","name":"joh
Here is my calling code:
$.get("mail/findUser.php",
alert("Queried ajaxemail" + result);
});
Printing the alert message works, I get the JSON encoded return, but I need to access individual elements of the JSON encoded return such as the ID or name field.
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
Thanks Hielo, but for some reason I still cannot access the individual elements of the returned data. This is what is being returned:
[{"id":"24695","name":"joh
$.get("mail/findUser.php",
$.each(json,function(i){
alert(json); <-- This prints fine it prints the above JSON output [{"id":"24695","name":"joh
alert("JSON Data: " + json[i].id + " " + json[i].name); <-- This is never printed
});
});
alert("Out of loop");
});
Even removing the loop and trying to print alert("JSON Data: " + json[0].id + " " + json[0].name); does not print any results.
I believe the JSON is valid, can you think of anything else that may be causing the issue? Thank you
Hielo,
That was my mistake I overlooked that part and you are correct in making that change, the expected results come through.
So that I am clear on the result. Using $.get will simply return a string value where as $.getJSON will return a JSON object.
In any case everything is working and I understand it now. Thank you again for your help.
Business Accounts
Answer for Membership
by: hieloPosted on 2009-08-07 at 22:11:08ID: 25048412
try:
Select allOpen in new window