update a div every so often

0

please I need help with the following I need to update a div that contains a table every certain time and I am using the following code

   <script type="text/javascript">
    $(document).ready(function() {
        var refreshId = setInterval(function() {
            $("#act1").load("../views/vistaLotes.php")
            .error(function() { alert("Error"); });
        }, 1000);

        $.ajaxSetup({ cache: false });              
    });
</script>

and I see that he does it but instead of updating the div what he does is about writing literal puts it on

I appreciate your help

    
asked by dmgarcia33 11.12.2017 в 21:47
source

3 answers

0

A quick fix would be this, it should work:

<script type="text/javascript">
    $(document).ready(function() {
        var refreshId = setInterval(function() {
            $("#act1").empty();
            $("#act1").load("../views/vistaLotes.php")
            .error(function() { alert("Error"); });
        }, 1000);

        $.ajaxSetup({ cache: false });              
    });
</script>

I'm already leaving but when I arrive I give you a more appropriate answer if nobody else does.

    
answered by 11.12.2017 в 21:52
0

What you could do is to empty the content of <div> in the following way:

<script type="text/javascript">
    $(document).ready(function() {
        var refreshId = setInterval(function() {
            $("#act1").html('');
            $("#act1").load("../views/vistaLotes.php")
            .error(function() { alert("Error"); });
        }, 1000);

        $.ajaxSetup({ cache: false });              
    });
</script>
    
answered by 11.12.2017 в 21:57
0

You must clean the div before painting the new data, so you need to add a call to the empty function and then upload the new content.
something like this:

$('#act1').empty().load("../views/vistaLotes.php")
    
answered by 11.12.2017 в 22:23