Refresh to div without loading other content

0

Good morning everyone!

I have a page in ASP that basically has 2 divs. A div where there is a panel that connects to a database and takes out information from there (a kind of dashboard) and a div where there is a slider of messages.

What happens: This page currently has an automatic refresh by HTML (tag) and it works fine! But for the sake of arriving an hour there will be more messages in this panel, it will not give you time to read them all before the page loads. I would like to see if there is any way to reload only the contents of the DIV of the panel that takes the data from the database. I saw some forms with JQuery, but most use a "load" function that needs to load a content inside, for example an html. Would not there be a way to do this directly in the document without any load from another file?

    
asked by anonymous 24.06.2015 / 15:07

1 answer

1

There are 2 ways to do this.

1 - Through Ajax (can be with jQuery or not) considering this the best option

<script type="text/javascript">
jQuery.ajax({
    url: 'nome-da-pagina.asp',
    type: 'GET', // Tb pode ser post
    async: false,
    success: function(data){
        alert('Dados carregados com sucess!');
        $('#id-do-div-para-update').html(data);
    },
    error: function(){
        alert('Falha carregando os dados!');
    }
});
</script>

Method documentation in jquery link

2 - Through iframe (not elegant but also works)

<iframe src="nome-da-pagina.asp" frameborders="0" width="100%" height="400"></iframe>
    
24.06.2015 / 20:45