0
I have an ajax that deletes an image, after the deletion, I would like the page to give a Reload and show a message of "Deleted Successfully!" with Alert boostratp. I’ve searched the forums and didn’t find anything that would help me.
jQuery(document).ready(function() {
jQuery('#teste').submit(function(){
var dados = jQuery( this ).serialize();
$.ajax({
type: 'POST',
dataType: 'json',
url: "crud/excluirImagem.php",
data: dados,
success: function(data) {
location.reload();
}
});
});
});
A solution
jQuery(document).ready(function() {
jQuery('#teste').submit(function(){
var dados = jQuery( this ).serialize();
$.ajax({
type: 'POST',
dataType: 'json',
url: "crud/excluirImagem.php",
data: dados,
success: function(data) {
$('.alert').fadeIn('2000');
setTimeout(function(){ reloadPagina() }, 3000);
}
});
return false;
});
});
function reloadPagina() {
location.reload();
}
I am obliged to give Reload, to "disappear" the images that have just been deleted.
– Alisson Hoepers
Just create the Alert on the same page, and then put a 10-second interval or less, then just give the Reload!
– Sampaio Leal
@Alisson you can also delete the images with . remove() or . Hide() in ajax’s Success...
– Jader A. Wagner
@Jader-a-Wagner hinted
– ShutUpMagda
A solution was found in the question I edited, what do you think?
– Alisson Hoepers
I think you should mark the question as answered...
– ShutUpMagda