Hi folks, I have a commenting system which is working well. I need to create an admin panel but for the time being I just want to have an asp.net page which auto loads every (n) seconds and shows me the latest posts from the post table. Its very simple (in concept). Anyone with some good links/pointers?
A:
Onload, start a javascript timer that refreshes the page after n seconds. Alternatively, you could put the data in an update panel and have the javascript update the updatepanel every n seconds, but then you would need to create a loop to call the javascript repeatedly, every n seconds.
MCain
2010-07-22 14:23:21
A:
I would suggest looking into the setTimeout/setInterval functions in Javascript that will call a specific function after the time has elapsed. In your case this will be an AJAX call to an ASPX page and then (i'm assuming) you'll want to fire the result into a DIV somewhere in your page...
setInterval(function(){
$.ajax({
url: 'test.aspx',
success: function(data) {
$('#myDiv').html(data); // fill div with response
}
});
}, 5000); // call after 5 secs
Something along those lines is roughly what i think you're after, although it is untested!
Cheers Stuart
Stuart
2010-07-22 14:27:10
So on test I would have a code on onload that fetches all data from my table right? How do I pass a parameter to the same? Say if I want to have an approve button on the page that sends back to test.aspx and updates a record? Do you have a sample code that would do this?
Kenyana
2010-07-22 14:36:59