I think my question is too shallow, but I explain the situation in more detail:
I already have the code and it works partially follows;
$(document).ready(function() {
var url = "dominio.com/json.php";
$.getJSON(url, function(result) {
console.log(result);
$.each(result, function(i, field) {
var id_rotina = field.id_rotina;
var treino = field.treino;
var grupo_id = field.grupo_id;
var user_id = field.user_id;
var id_grupo = field.id_grupo;
var nome_grupo = field.nome_grupo;
var anatomia = field.anatomia;
var id_exercicio = field.id_exercicio;
var nome_exercicio = field.nome_exercicio;
var repeticoes = field.repeticoes;
var intervalo = field.intervalo;
if(treino == 'treino-b'){
$("#grupo-b").append(
"<div class='serie'> <div class='mostra-grupo-b'>"
+ nome_grupo
+ "<div class='visualizar'>VER</div>"
+ "</div>"
+ "<div class='anatomia'>" + anatomia + "</div>"
+ "<table class='grupo-b' align='center'><thead><td class='exe'>Exercício</td><td>Reps</td><td>Int</td></thead><tbody>"
+ "<td>"+ nome_exercicio +"</td>"
+ "<td>"+ repeticoes +"</td>"
+ "<td>"+ intervalo +"</td>"
+ "</tbody></table></div>");
}
});
});
});
It prints correctly when it has only one element to print when it has more than one it duplicates the variable 'group_name' and table.
My question really is: How do I display the variables correctly?