通过ajax显示JSON数组(jquery)

eek*_*eek 2 arrays ajax jquery json

我是Ajax和JSON的新手,并试图让它工作,但似乎无法掌握它.

如何在ajax中调用json并显示json文件中的所有信息?

这是我的json文件

{ posts: [{"image":"images/bbtv.jpg", "alter":"BioBusiness.TV", "desc":"BioBusiness.TV", "website":"http://andybudd.com/"}, {"image":"images/grow.jpg", "alter":"Grow Staffing", "desc":"Grow Staffing", "website":"http://growstaffing.com/"}]}
Run Code Online (Sandbox Code Playgroud)

和使用的ajax函数

$.ajax({
       type: "GET",
       url: "category/all.js",
       dataType: "json",
       cache: false,
       contentType: "application/json",
       success: function(data) {

            $.each(data.posts, function(i,post){
                            $('#folio').html('<ul><li><div class="boxgrid captionfull"><img src="' + post.image + '" alt="' + post.alter + '" /><div class="cover boxcaption"><p>' + post.desc + '</p><a href="' + post.website + '" target="_blank">More Work</a></div></div></li></ul>');

                    });

            initBinding();
       },
       error: function(xhr, status, error) {
         alert(xhr.status);
       }
    });
Run Code Online (Sandbox Code Playgroud)

出于某种原因,它只显示最后一项....

任何正确方向的帮助都会很棒.

谢谢!

kgi*_*kis 5

尝试这样的事情:

$('#folio').html("<ul/>");
$.each(data.posts, function(i,post){
   $('#folio ul').append('<li><div class="boxgrid captionfull"><img src="' + post.image + '" alt="' + post.alter + '" /><div class="cover boxcaption"><p>' + post.desc + '</p><a href="' + post.website + '" target="_blank">More Work</a></div></div></li>');
});
Run Code Online (Sandbox Code Playgroud)