如何从JSON中读取列表并以li
的形式附加到HTML中?
digikala.menu
在JSON中是ul
request.onload = function () {
var digikala = request.response;
for (var i = 0; i < digikala.menu.length; i++) {
var name = digikala.menu[0];
var ul = document.getElementById("navigation_item");
var li = document.createElement('li');
li.appendChild(document.createTextNode(name));
ul.appendChild(li);
}
}