[英]Reloading a partial view when a function in the view completes?
I've made a scrolling ticker to keep track of live stats as they enter a database, it's in its own partial view, but I'm wondering if its possible to refresh the div with new information when the scrolling function completes in the partial view so that new data is displayed in a timely manner without having to reload the whole page. 我制作了一个滚动报价器来跟踪实时统计数据进入数据库时的实时状态,它处于其自己的局部视图中,但是我想知道当局部视图中的滚动功能完成时是否有可能用新信息刷新div这样就可以及时显示新数据,而不必重新加载整个页面。
I call it simply with : 我简单地用:
@Html.Partial("Ticker", Model)
Where Model is the data used in the view. 其中模型是视图中使用的数据。
Example of what the ticker looks like: http://www.smoothdivscroll.com/runningTicker.html 代码显示示例: http : //www.smoothdivscroll.com/runningTicker.html
Implement the Ticker
action: 实施
Ticker
操作:
public PartialViewResult Ticker(int param) {
TickerModel model = new TickerModel();
// TODO: fill the model
return PartialView(model);
}
and then invoke it form the JavaScript function: 然后从JavaScript函数调用它:
function reload() {
$.ajax({
url: '@Url.Action("Ticker")',
data: { param: .... },
success: function (data) {
$("#TickerDiv").html(data);
}
});
}
Instead of 代替
@Html.Partial("Ticker", Model)
use 采用
<div id="TickerDiv">
@Html.Action("Ticker", new { param = .... })
</div>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.