hi,
in my jquery code, i made ajax request and server returned data in JSON like this:
{"list":{
"category":"book",
"item":[
{"title":"jQuery Cookbook","author":"Tom","publisher":"Wonderland"},
{"title":"PHP Cookbook","author":"Jack London","publisher":"O'Reilly"}
]
}
}
in my jquery code, i have:
$.getJSON(
"data/getFile.php",
{set:setName, list:listName},
function(json) {
var items = json.list.item;
$.each(items, function(key, value) {alert(value);}
});
it turned out value is a object, which is right. my question is how i can parse out both the name and value like : for item 1: key="title", value="jQuery Cookbook"; key="author", value="Tom";...
the reason i need to do this is the item will update dynamically, maybe later user will add more key/value attribute, for example: {"isbn": "11223344"}
Thanks.