Get array's elements and append them to div
I get the string array from a web service. Now I want to display the data in a div. However it is not working(nothing is shown)
Thanks for help.
- <!DOCTYPE html>
<html>
<head>
<title>Mars</title>
<meta charset="utf-8" />
</head>
<body>
<div id='photo'>
</div>
<script src="http://ajax.aspnetcdn.com/ajax/jQuery/jquery-2.0.3.min.js"></script>
<script>
$(function () {
var id = 1000;
var url = '/api/Photo/' + id;
$.getJSON(url)
.done(function (data) {
$.each(data, function (index,value) {
$('photo').append('<li>' + value + '</li>');
});
});
});
</script>
</body>
</html>
Let's say data likes
-
"one", "two", "three", "four", "five"