Catch certain part of the html coming from another page with javascript

0

Hello everyone, I want to get a specific area of what is coming from the other page, for example what comes from the other page, I get the div with id like I would with my script?

<script type="text/javascript">
        // Função responsável por atualizar as frases
        function atualizar()
        {
            // Fazendo requisição AJAX

$('#mensagensinbox').load("functions/atumensainbox.php?id_log_ass=<?php echo $id_log_ass;  ?>");


        }
        // Definindo intervalo que a função será chamada
        setInterval("atualizar()", 10000);
        // Quando carregar a página
        $(function() {
            // Faz a primeira atualização
            atualizar();
        });
    </script>
    
asked by anonymous 02.09.2016 / 03:06

1 answer

1

Good night Gezer, you need to know the identifiers you want to get inside html returned by $.load() .

Note that the html returned by $.load() will be loaded in div #messagesinbox .

You just need to find the identifiers in #messagesinbox .

Imagine that html of the page that was loaded returns:

<!-- muitos outras tags acima -->
<div class="mensagens">
   <span class="titulo"> Boa noite</span>
   <p class="mensagem">Oi, como vai você, queria te desejar boa noite.</p>
</div>
<!-- muitas outras tags abaixo -->

For you to get a specific content within all of those tags that were returned, it would look something like this:

var mensagens = $("#mensagensinbox").find(".mensagens");

Finally, if you give console.log(mensagens[0]); you will notice the following html .

<div class="mensagens">
<span class="titulo"> Boa noite</span>
<p class="mensagem">Oi, como vai você, queria te desejar boa noite.</p>
</div>

To conclude, within all content returned in the load function, you just picked up the div that contains the class .messages .

I hope I have helped.

    
02.09.2016 / 03:14