0

我正在为 javascript 模板使用 jQote 库,以下是我对 ajax 请求的JSON响应

{"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>
4

1 回答 1

0

我删除后它起作用了

 var dataJson = $.parseJSON(res);

并将 jQote 函数编辑为:

 $('#users').jqotesub('#template', res);
于 2012-08-07T11:27:24.963 回答