I have a modal alert where it shows the information of different types of alerts and the same alerts are coming 3 times and my question is what I can do to prevent this from happening.
$('#modalAlert').modal('show');
$.ajax({
url:"<?php echo CController::createUrl('agenda/comentarioLlegada') . '?tipo='; ?>"+user.tipoLlegada+"&tipoA="+user.tipo+" &id=" +user.id+ "&comentario=ND&clasificacion=1",
type:'GET',
dataType:'html',
async: false,
success:function(resp){
var elementos = $("#contadorItems").val();
elementos = parseInt(elementos)+1;
$(".valorNumEventos").html("");
$(".valorNumEventos").append(" "+elementos+" ");
$("#contadorItems").val(elementos);
var cantidad = parseInt($("#valor"+user.tipo).attr('rel'))+1;
$("#valor"+user.tipo).attr('rel',cantidad);
$("#valor"+user.tipo).html("");
$("#valor"+user.tipo).append(cantidad);
$("#cuerpoAlerta").append('<tr id ="tr'+user.id+user.tipo+'" ><td>'+user.title+'</td><td>'+user.descripcion+'</td><td>\n\
<textarea id="Comentario'+user.id+user.tipo+'" name="Comentario'+user.id+user.tipo+'"></textarea></td><td>\n\
<button rel="'+user.id+'" rel2="'+user.tipoLlegada+'" rel3="'+user.tipo+'" type="button" onclick="guardarComentario(this)" class="btn btn-primary"><i class="far fa-save"></i></button></td><tr>');
$('#modalAlert').on('hidden.bs.modal', function () {
localStorage.setItem('alerta','0');
// alert(localStorage.getItem('alerta'));
})
}
});