1
I made a script to set an image as cover, the script works perfectly and I programmed the same to perform a Reload on the return, but strangely this Reload fails in a few moments, for no apparent reason.
This is the script:
$(function() {
$("[name='btncapa']").on('click', function(e) {
var id_equipe = $(this).attr('id_equipe');
var id_equipe_img = $(this).attr('id_equipe_img');
var $el = $(this);
bootbox.dialog({
message: "Confirma a marcação de capa para foto?",
title: "Capa",
buttons: {
success: {
label: "Sim",
className: "btn-success",
callback: function() {
$.getJSON('CapaFotoEquipe.php', {
id_equipe: id_equipe,
id_equipe_img: id_equipe_img
}, function(resposta) {
$("#diverro").html("<div class='alert alert-error'><button type='button' class='close' data-dismiss='alert'>×</button><strong>ERRO!</strong> " + resposta.erro + "</div>");
});
// RELOAD NO RETORNO
location.reload(true);
}
},
danger: {
label: "Não",
className: "btn-danger",
callback: function() {}
}
}
});
e.preventDefault();
});
});
Put Location.Reload(true); inside Function(response)
– pho3nix
Hello @pho3nix, had already done this test the script does nothing.
– adventistapr
Because javascript is asynchronous, put na inside the get callback() Function. Have you tried window.location.Reload(true)? @adventistapr
– LucaoA