I have an ajax that deletes an image, after the deletion, I would like the page to reload and display a "Deleted successfully!" message. with alert boostratp. I already researched the forums and did not think it 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();
}
});
});
});
One 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();
}