如何在MVC 2应用程序中创建twitter自动刷新效果?
感谢
答案 0 :(得分:0)
您可以使用setInterval javascript函数,该函数允许您定期执行某些代码。然后,您可以向服务器发送AJAX请求,以查看是否有更新并刷新页面的某些部分。以下是如何轮询服务器操作以获取更新的示例:
window.setInterval(function() {
// this will execute every 5 seconds
// send an AJAX request
$.get('/someaction', { }, function(result) {
// use the result returned from the server
// to update the DOM
});
}, 5000);