我有来自控制器的 JSON,如下所示:
{"ja":
[
{
"ID":0,
"Name":"Son",
"DepartmentID":0,
"isNewProduct":false,
"PictureName":null,
"isInstock":false
}
,
{
"ID":0,
"Name":"AM4-B2",
"DepartmentID":0,
"isNewProduct":false,
"PictureName":null,
"isInstock":false
}
,
{
"ID":0,
"Name":"AM4-B2",
"DepartmentID":0,
"isNewProduct":false,
"PictureName":null,
"isInstock":false
}
]
}
这是我要点击的菜单:
<ul id="navmenu-v">
<li id="select_list" class="level1">
<a id="56" class="selectedcategory" href="javascript:void(0);">Accessories</a>
</li>
<li id="select_list" class="level1">
<a id="69" class="selectedcategory" href="javascript:void(0);">Audio Players</a>
</li>
</ul>
这些是我想将每个 json 放入的 div:
<div id="container">
<div id="id"></div>
<div id="name"></div>
<div id="departmentID"></div>
<div id="isNew"></div>
<div id="pictureName"></div>
<div id="isStock"></div>
</div>
然后我想在单击菜单时将所有 JSON 循环到视图旁边的不同 div 中。
谁能告诉我如何使用$.getJSON()
and 来做到这一点$.each()
?非常感谢。