通过 ajax 调用刷新局部视图挂起应用程序
Refreshing partial view via ajax call is hanging app
MVC5 应用程序我每 5 秒刷新一次部分视图,但是几分钟后应用程序挂起,客户端浏览器错误
net::ERR_INSUFFICIENT_RESOURCES
调用局部的代码在这里
function setupRefresh() {
$.ajaxSetup({ cache: false });
// ajax load partial view
$("#PartialViewPlaceHolder").load("/testController/GetTestPartialView");
// refresh count every 5 seconds
$(function() {
window.setInterval(setupRefresh, 5000);
});
}
我的部分代码是
<div class="col-md-12">
@if (Model.TestCount > 0)
{
<p class="alert alert-info">
There are <strong>@Model.testCount</strong> widgets in this batch
</p>
@ShowButton()
}
else
{
<p class="alert alert-info">
There are no widgets
</p>
}
</div>
@helper ShowButton()
{
@Html.ActionLink("Do something", "GetPartialView", "TestController", new {@class = "modal-link btn btn-primary btn-lg
btn-block"}) }
此片段必须在 setupRefresh() 之外
$(function() {
window.setInterval(setupRefresh, 5000);
});
MVC5 应用程序我每 5 秒刷新一次部分视图,但是几分钟后应用程序挂起,客户端浏览器错误
net::ERR_INSUFFICIENT_RESOURCES
调用局部的代码在这里
function setupRefresh() {
$.ajaxSetup({ cache: false });
// ajax load partial view
$("#PartialViewPlaceHolder").load("/testController/GetTestPartialView");
// refresh count every 5 seconds
$(function() {
window.setInterval(setupRefresh, 5000);
});
}
我的部分代码是
<div class="col-md-12">
@if (Model.TestCount > 0)
{
<p class="alert alert-info">
There are <strong>@Model.testCount</strong> widgets in this batch
</p>
@ShowButton()
}
else
{
<p class="alert alert-info">
There are no widgets
</p>
}
</div>
@helper ShowButton()
{ @Html.ActionLink("Do something", "GetPartialView", "TestController", new {@class = "modal-link btn btn-primary btn-lg btn-block"}) }
此片段必须在 setupRefresh() 之外
$(function() {
window.setInterval(setupRefresh, 5000);
});