[英]how to iterate through json list and embed to html
我進行了ajax調用以從數據庫檢索數據,並且數據以JSON格式返回。 我想設計一個“視圖”來顯示數據。 充其量,我只是將數據粘貼到視圖中並顯示數據。 有人可以幫我嗎?
注意:該圖像是針對min的,而sockOutJS隨附的CMS是我正在使用的新技術
![在此處輸入圖片描述] [1]
到目前為止,我的消息來源:
<script type="text/javascript">
$(function () {
$("#btnSearch").click(function () {
$.ajax({
url: "../ideapark/DesktopModules/ResourcesFilter/AjaxHandler.ashx/",
dataType: "json",
type: "POST",
data: {
'action': 'ResponseFilterSearch'
, 'Keyword': $('#txtbKeyword value').val()
, 'Skill': $("#ddlSkills option:selected").val()
,'Types' : $("#ddlTypes option:selected").val()
, 'Topics': $("#ddlTopics option:selected").val()
, 'SortBy' : $("#ddlSortBy option:selected").val()
},
success: function(data) {
for(var i = 0; i < data.length; i++)
{
//t ajax handler recollection of resources.
//U NEED TDESERIALIZE
//var resID = data.response[i].ID;
//var summary = data.response[i].Summary;
//var pageID = data.response[i].PageID;
//var name = data.response[i].Name;
//var createdOn = data.response[i].CreatedOn
//var Total = data.response[i].Total;
}
},
error: function(XMLHttpRequest, textStatus, errorThrown)
{
console.log(errorThrown);
console.log(XMLHttpRequest);
console.log(textStatus);
console.log(errorThrown);
}
});
});
});
</script>
的HTML
<div class="resourcesResult">
<input type="hidden" name="dnn$ctr687$View$rp_resList$ctl00$hf_resID" id="dnn_ctr687_View_rp_resList_hf_resID_0" value="71">
<a href="http://ideapark.rtraction.com/WebsofWonder/IWonderWhereTheAnimalsGoInTheFall.aspx">I Wonder Where The Animals Go In The Fall</a>
<br>
Students begin to understand where the animals in their environment are going in the fall
<br>
<h6>
<a id="lnkBtnTags_0" href="">observing</a>
</h6>
<h6>
<a id="lnkBtnTags_1" href="">change</a>
</h6>
<h6>
<a id="lnkBtnTags_2" href="">animal</a>
</h6>
<h6>
<a id="lnkBtnTags_3" href="">fall</a>
</h6>
<h6>
<a id="lnkBtnTags_4" href="">autumn</a>
</h6>
<h6>
<a id="lnkBtnTags_5" href="">five senses</a>
</h6>
<h6>
<a id="lnkBtnTags_6" href="">winter</a>
</h6>
<h6>
<a id="lnkBtnTags_7" href="">hibernation</a>
</h6>
<h6>
<a id="lnkBtnTags_8" href="">migration</a>
</h6>
<h6>
<a id="lnkBtnTags_9" href="">adapt</a>
</h6>
<h6>
<a id="lnkBtnTags_10" href="">seasons</a>
</h6>
<input type="button" value="Share">
</div>
</div
>
也許您可以使用諸如handbars之類的 javascript templating library
。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.