0
Good afternoon! I make a request via AJAX to open a modal. I list a data set and have the option to delete the record from the table. The problem is that whenever I delete a record the page gives refresh and the modal closes. There will be a way to keep the modal open and delete all the records you wanted without it closing?
The button code I call the modal is this, where $registrations[0] is an id passed to the modal.
<button type='button' class='btn btn-info' style='outline: 0;' onclick='$.fn.del(" . $registos[0] . ")'>Plantel</button>
In the click I make a request via AJAX. The code is this:
$.fn.del = function (id) {
var a = id;
// alert(a);
$.ajax({
url: "del_at_modal.php",
method: "POST",
data: {id: a},
success: function (data) {
$("#form_del_at").html(data);
$("#del_at").modal("show");
}
});
};
The modal showing the contents of this request is
<div class="modal fade" id="del_at" data-backdrop="static">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">×</span></button>
<h2 class="modal-title">Adicionar atletas à equipa </h2>
</div>
<div class="modal-body" id="form_del_at"></div>
<div class="modal-footer">
<input type='reset' name='cancelar' class="btn" value='Cancelar' />
<button type="submit" class="btn btn-success" name="novos_t">Adicionar equipa técnica</button>
</div>
</div>
</div>
</div>
And in the file, del_at_modal.php, I query the table list the fields I want and at the end I have this field to delete the record
<td title="Remover atleta da equipa"><a href="el_atleta_equipa.php?cod_atleta=' . $registos[0] . '">X</td>
To do this without updating the page, you would have to use another ajax.
– Sam
@dvd and how would you do that? where would you implement another ajax?
– Tiago Simoes