Refresh in div without loading other content

Asked

Viewed 5,292 times

0

Good morning, everyone!

I have a page in ASP that has basically 2 Divs. A div where there is a panel that connects to a database and takes 3 information from there (a kind of Dashboard) and a div where there is a panel of messages that keep passing (slider).

What happens: this page is currently with an automatic refresh by HTML (tag) and until it works well! But, for reasons of arriving an hour there will be more messages in this panel, will not give time to read all before the page load. I’d like to see if there’s any way to reload only the contents of the DIV panel that picks up the database data. I saw some forms with Jquery, but most use a "load" function that needs to load a content inside, for example an html. There would be no way to do this directly in the document without any other file load?

  • Probably Ajax + javascript solves your problem...

  • 1

    Rodrigo took a look at this question/answer: http://answall.com/q/6626/129

  • You need to use Ajax + JSON + Jquery. Your data must be dynamic to the point of consuming JSON objects.

1 answer

1


There are 2 ways to do this.

1 - Through Ajax (may 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>

Documentation of the jquery method http://api.jquery.com/jQuery.ajax/

2 - Through iframe (not elegant, but also works)

<iframe src="nome-da-pagina.asp" frameborders="0" width="100%" height="400"></iframe>
  • Gildonei, thank you very much for your feedback and explanation. Just one question: where there is "url", how can I do? Because for example, it is a page only that I have, in this case a page called "panel.Asp", all content is on this page and no content is taken from another page, however, only the DIV that I call here "Dashboard" needs to be updated at all times. Already the DIV "messages" must remain running (slider) without being updated from time to time.

  • @Rodrigobrf Ali where there is url:, you will replace the 'page-name.Asp' with 'panel.Asp'. Remembering that.Asp panel should contain only the content that should be loaded, without layout or formatting, only the text/images that should appear.

  • I understood, but in the case here, for example, this panel makes a connection with a DB to pull some data. It would work?

  • Yes, it works normally, it remains a normal Asp page, you can do everything normally in it, but consider that it should show only the content, if u put layout, will open a page with layout within the div, understood?

  • Perfect! Thank you!!

Browser other questions tagged

You are not signed in. Login or sign up in order to post.