Update DIV with popover attribute

1

I have a function where I get charged every 10s. When checking that there is a new message updates the field informing the amount of messages.

smg();
        function smg() {
            setTimeout(smg, 10000); // 10 seg
            $.getJSON("mensagemVerifica.php", {ID_Cadastro: <?php echo $_SESSION['ID_Cadastro']; ?>}, function(json){

                if (json.length == 0){
                    $(".mensagensAdminNum").html('0');
                }else{
                    $.playSound("sons/msgAlerta.mp3");
                    $(".mensagensAdminNum").html(json[0].totalMsg);
                }
            });
        };

So long so good ...

But since there is no reload on the page, the message list does not appear.

Is there a way to update the DIV below without having to reload the page?

$(".mensagensAdmin").attr("data-content",
            '<div class="mensagensAdminDiv">' +
            '   <?php while ($rowMsg = $rsMsg->fetch_assoc()) {?>\n' +
            '       <button onclick="location.href=\'projetoProposta.php?cod=<?php echo $rowMsg['projeto'] ?>\'" type="button" class="btn btn-info btn-block" style="margin-bottom: 5px;\n"><?php tituloMSG($rowMsg['projeto']); ?></button>\n' +
            '   <?php } ?>' +
            '</div>'
        );
    
asked by anonymous 18.08.2017 / 21:26

0 answers