I have the following jQuery:
$("#apagar-marcados").click(function(){
var lista_marcados = document.getElementsByName('id_mensagem[]');
$.each(lista_marcados, function(i, item){
if ($(item).prop('checked')){
$.ajax({
type: "POST",
url: BASE_URL + "ajax/remover_mensagem",
data:{id_mensagem: $(item).val()},
cache: false,
success: function(){
alert('atualizado')
}
});
}
});
});
In this, I do the update via SQL in the database, until then, works perfectly. In this case, I have a listing with checkbox, which in turn, marked, with the click the delete button, will enter this action.
The problem is, that if I select 10 checkbox, alert('atualizado')
10x will appear, how do I make it appear only once?