I got an Json object by using jQuery's getjson() method like that:
<script>
$(document).ready(function(){
$("button").click(function(){
$.getJSON(the_api_url, {}, function(data) {
// do something
});
});
});
});
</script>
The data is an array list, and its format is like this:
[
{
id : "001",
name : "apple",
class : "fruit",
colour : "red"
},
{
id : "002",
name : "melon",
class : "fruit",
colour : "green"
},
{
id : "003",
name : "banana",
class : "fruit",
colour : "yellow"
}
]
I am new to JavaScript and don't know how to parse and display it in html page. Could you guys help me with the code in the '//do something' part?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…