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);
        }
    });   
});

そしてここで私はオブジェクトを出そうとしていますが、エラーが私にこれを与えています
.Person is undefined

これは、オブジェクトを反復処理したいので、オブジェクトを出力しようとしている方法です

<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 に答える