【问题标题】:Calling Object using jQote jQuery使用 jQote jQuery 调用对象
【发布时间】: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


    【解决方案1】:

    我删除后它起作用了

     var dataJson = $.parseJSON(res);
    

    并将 jQote 函数编辑为:

     $('#users').jqotesub('#template', res);
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2013-01-19
      • 1970-01-01
      • 2014-12-11
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多