【发布时间】:2012-08-07 11:20:17
【问题描述】:
我正在使用 jQote 库作为 javascript 模板 以下是我的 JSON 来自 ajax 请求的响应
{"Person":[{"actor_image":"Image1","actor":"Name1"}]}
以下是jQuery代码
$(document).on('click',".notifications",function(){
$("#notificationRegionWrapper").toggle();
$.ajax({
type: 'post',
url: "/async/getnotificationfeed",
dataType: 'json',
async:false,
success: function(res) {
var dataJson = $.parseJSON(res);
$('#users').jqotesub('#template', dataJson);
}
});
});
在这里我试图取出对象,但给我一个错误
this.Person 未定义
这是我试图输出对象的方式,因为我想迭代对象
<table id="users">
</table>
<script type="text/html" id="template">
<![CDATA[
<tr>
<td class="title"><%= this.Person.length %></td>
</tr>
]]>
</script>
【问题讨论】:
标签: jquery underscore.js jqote