Update page when closing a modal

Asked

Viewed 1,520 times

1

How do I update a page whenever the modal is closed ? because I have a problem that whenever I close the modal and I will open again it does not open... so I need to update the page then it opens.

used modal

<div class="modal fade bd-example-modal-lg" id="modalInfoMaq" role="dialog">
        <div class="modal-dialog modal-lg">
            <div class="modal-content">
                <div class="modal-header">
                    <h5 class="modal-title" id="modaleditcadastro">Informaçoes maquina:</h5>
                    <button type="button" class="close" data-dismiss="modal" aria-label="Close" onclick="AtualizarPagina()">
                        <span aria-hidden="true">&times;</span>
                    </button>
                </div>
                <div class="modal-body">
                    <div class="container-fluid">
                        <div class="row">
                            <div class="col-lg-12">
                                <form>
                                    <div class="col-sm-6" style="display: none;">
                                        <div class="input-group input-group-lg" >
                                            <span class="input-group-addon" id="sizing-addon1">Numero Serie</span>
                                            <input type="text" class="form-control" name="serie_maquina" id="serie_maquina" readonly="readdonly">
                                        </div>
                                    </div>
                                    <div class="col-sm-6" style="display: none;">
                                        <div class="input-group input-group-lg" >
                                            <span class="input-group-addon" id="sizing-addon1">Modelo</span>
                                            <input type="text" class="form-control" name="grupo_maquina" id="grupo_maquina" readonly="readdonly">
                                        </div>
                                    </div>
                                </form>
                                <div class="row">
                                    <div id="maquina_carrega" class="col-8 col-sm-6">
                                    </div>
                                    <div id="maquina_carrega_rec" class="col-8 col-sm-6">
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="modal-footer">
                </div>
            </div>
        </div>
    </div>

and the script that sends the data to the modal

<script>
$(document).on("click", "#btnInfoMaq", function () {
    var info = $(this).attr('data-id');
    var str = info.split('|');
    var serie_maquina = str[0];
    var grupo_maquina = str[1];
    $(".modal-body #serie_maquina").val(serie_maquina);
    $(".modal-body #grupo_maquina").val(grupo_maquina);
    console.log(serie_maquina);
    console.log(grupo_maquina);
    $.ajax({
        type:'post',
        url: 'info_maquina.php',
        data: {
            'serie':serie_maquina,
            'grupo':grupo_maquina
        },
        async:false,
        erro: function () {
            alert('erro');
        },
        success: function (data) {
            //$("#maquina_carrega").html(data);
            $("#maquina_carrega").html(data);
        }

    });
});

the problem is that when I open it once... and close, when I try to open again it opens and closes. and then does nothing else.

  • Reloading the page can cause a bad experience for the user, maybe it would be better to identify the reason the modal does not open again. Edit your question and include your code so we can assist you.

  • Can you post the code you are using? Just you edit your question.

  • Edited! if you can give me a light thank you

1 answer

1


Use window.location.href to capture the current page and window.location.href=URL to redirect to a page.

Ex.:

var urlAtual = window.location.href;
window.location.href=urlAtual; // aqui vai fazer o redirecionamento

:)

Browser other questions tagged

You are not signed in. Login or sign up in order to post.