I have a return of type JSON that I'm trying to insert into the div, but it's all inserted one on top of the other.
<!-- DIV que vai receber as informações -->
<section>
<div class="conteudo">
<div class="foto"> FOTO </div>
<div class="inf"> TITULO </div>
<div class="inf"> DESCRICAO </div>
<div class="inf"> PRECO </div>
</div>
<div class="conteudo">
<div class="foto"> FOTO </div>
<div class="inf"> TITULO </div>
<div class="inf"> DESCRICAO </div>
<div class="inf"> PRECO </div>
</div>
My loop to try to populate the divs
$("#menu li").click(function() {
var id = $(this).attr("id");
$.ajax({
type: 'GET',
url: "categoria/"+id,
contentType: "charset=utf-8",
}).done(function(output){
json = $.parseJSON(output);
$('.conteudo').empty();
$.each(json, function(i, items){
$('.conteudo').append(
items.fields['imagem'],+
items.fields['nome_produto']+
items.fields['descricao']+
items.fields['preco_produto']
);
});
});
return false;
});
I need to put the contents of each json field in their respective div. I tried to insert id instead of css classes to identify. I have also tried using the .append (), .clone (), addClass (), appendTo but unsuccessful methods. If you can help me.