Refresh DIV without giving refresh on page JQUERY

2

Good afternoon Hi, I have an Ajax application that I am trying to use. I have a PHP file which I am trying to use. In the case I would like to update only the div and nothing else is just to run the foreach again that will get the data of the session that now has one more item so that I am not getting anyone can help?

$(document).ready(function() {
                  $('.incluir_item').submit(function() {
                    var dados = $(this).serialize();
                    $.ajax({
                      type: "POST",
                      url: "calibracao_incluir_itens.php",
                      data: dados,
                      beforeSend: function() {
                        $('#incluir-item').fadeOut('fast').modal('toggle');
                        $('<div class="ajaxModal"><div class="ajaxModal-preload"><p>Incluindo cliente aguarde!</p></div></div>').insertAfter('body');
                        $('.ajaxModal').fadeIn('fast');
                      },
                      success: function(data) {
                        ajaxModal_Close();
                        $('#tabela_calibracaoes').html('#tabela_calibracaoes');

                      }



                    });
                    return false;
                  });
                });

Thank you in advance.

    
asked by anonymous 24.06.2016 / 19:41

3 answers

1

The sure thing would be to "crash" the submit event. On the first line, enter:

event.preventDefault();

This will not make the submit perform its function, and will continue with the rest of the code.

    
24.06.2016 / 19:59
0

I am sending the example how to use ajax updates without refreshing the page.

See $('div#lista').html(texto); is same place (html) , and you want to insert more text $('div#lista').append(texto); (append)

$(document).ready(function() {
	$('input#refresh').bind('click', function() {
		$.getJSON('http://beta.json-generator.com/api/json/get/4yIDEw8S-', function(json) {
          var texto = JSON.stringify(json);
		  $('div#lista').html(texto);
        });
	});
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script><divid="lista"></div>
<br><input type="button" id="refresh" value="Refresh">

See you soon!

    
24.06.2016 / 20:10
-2

To lock submit use return false; at the end of .submit (function (){}) .

    
25.06.2016 / 17:48