Reload failing in some moments

1

I made a script to set an image as a cover, the script works perfectly and I programmed it to perform a reload on the return, but strangely this reload fails in some moments for no apparent reason.

The script is this:

    $(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'>&times;</button><strong>ERRO!</strong> " + resposta.erro + "</div>");
                        }); 
                        // RELOAD NO RETORNO                                                    
                        location.reload(true);
                    }
                },
                danger: {
                    label: "Não",
                    className: "btn-danger",
                    callback: function() {}
                }
            }
        });
        e.preventDefault();
    });
});
    
asked by anonymous 16.06.2016 / 22:43

0 answers