Problem with modal registration form

Asked

Viewed 552 times

1

  • In the registration form I call a window modal which is the same page of listing entries.

  • When I click on submit of form it sends to my beauty database and closes the modal.

However, for me to see the change on the screen, it is necessary to give a refresh on the page. How can I click on submit and at the same time give a refresh on the page?

I tried it like this, but it kept giving refresh straightforward!

<script type="text/javascript">
  var timeout = setTimeout("location.reload(true);",2000);
  function resetTimeout() {
    clearTimeout(timeout);
    timeout = setTimeout("location.reload(true);",2000);
  }
</script> 
<button type="submit" class="btn btn-default" onclick="resetTimeout()">Cadastrar</button>

<!--Butao adicionar -->
<button href="#my-modal" class="btn btn-primary btn-lg" data-toggle="modal" data-target="#myModal">+ Adicionar</button>
<!-- Modal -->
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
  <div class="modal-dialog">
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
        <h4 class="modal-title" id="myModalLabel">Adicionar G&aacute;s </h4>
      </div>
      <div class="modal-body">
        <form method="post" action="" id="quick-post-form" enctype="multipart/form-data">
          <div class="form-group">
            <label>Nome</label>
            <input class="form-control" name="Nome">
          </div>
          <div class="form-group">
            <label>Pre&ccedil;o</label>
            <input class="form-control" name="preco">
          </div>
          <div class="form-group">
            <label> </label>
          </div>
          <div class="form-group">
            <label>Imagem</label>
            <input type="file" name="image-uploader" id="img-upload">
            <img height="80" width="80" id="image-preview" src="" style="display:none;">
            <input type="hidden" name="operacao" value="normal">
          </div>
          <div class="form-group">
            <label></label>
          </div>
          <button type="submit" class="btn btn-default">Enviar</button>
          <button type="button" class="btn btn-default" data-dismiss="modal">Cancelar</button>
        </form>
      </div>
      <div class="modal-footer">
        <button type="button" class="btn btn-default" data-dismiss="modal">Cancelar</button>
      </div>
    </div>
    <!-- /.modal-content -->
  </div>
  <!-- /.modal-dialog -->
</div>
<!-- /.modal -->
  • 1

    Just do location.reload() after you close the modal.

  • How would it look in javascript could give me that strength there ?

  • You said that "when I click on the form’s Ubmit it sends to my database blz and closes the modal.". Where is the code that makes the Submit and closes the modal ?

  • I’ll put it down here

  • It’s for editing and asking your question, young man. And another, it’s not the code you save. That’s the HTML. Where’s the JS ?

  • refresh in the submit will not help to show what is not yet registered...

Show 1 more comment

1 answer

0


Update when closing the modal:

<script type="text/javascript">
 $(function(){
   $('#myModal').on('hidden.bs.modal', function () {
     window.location = window.location;
   });
</script>

Browser other questions tagged

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