1
I got 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 update via SQL in the database, until then, works perfectly. In this case, I have a checkbox listing, which in turn, marked, with the click of the delete button, will enter this action.
The problem is, if I select 10 checkbox, the alert('atualizado')
10x, as I do to appear only once?
The return of function
$.ajax
is a Promise, then you can try using thePromise.all()
, but why not send all values in the same request already?– Woss
Because I don’t know how to do this @Andersoncarloswoss, in PHP I know how to update everyone who comes in the post(id_message) through the array, but I don’t know how to pass the array().
– Sr. André Baill