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 simp开发者_运维知识库le (in concept). Anyone with some good links/pointers?
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.
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
精彩评论