4
我需要自动刷新partialView在每一秒钟(或设定的时间间隔)如何自动刷新MVC PartialView每秒
我想下面的方法的页面是这个仪式
loop
{
setInterval(function() { <%Html.RenderPartial("partialview", Model);%> } ,1000);
}
还是有更好的方法使用Ajax的东西?
我需要自动刷新partialView在每一秒钟(或设定的时间间隔)如何自动刷新MVC PartialView每秒
我想下面的方法的页面是这个仪式
loop
{
setInterval(function() { <%Html.RenderPartial("partialview", Model);%> } ,1000);
}
还是有更好的方法使用Ajax的东西?
最简单的方法是获得一个Controller动作,它返回你的局部视图,然后在setInterval函数中创建一个ajax get请求。类似这样的:
$.ajax({
url: '/MyController/PartialViewAction',
type: "GET",
success: function(result) {
$("#partialContainer").html(result);
}
});
非常好,谢谢。这是一种享受。 – 2011-07-20 16:01:27
你能张贴你的部分视图吗? – JonoW 2009-10-02 11:09:50