I'm using Asp.net MVC and I want my partial view to refresh on an interval, which it does until I make an unrelated Ajax request, then it stops.
Here are a few simplified snips to illustrate the problem.
in AjaxRefresh.js:
function ajaxRefresh()
{
var f = $("#AjaxForm");
$("#AjaxLoading").show();
$.post(f.attr("action"), f.serialize(), function (context) {
$("#AjaxDiv").html(context);
$("#AjaxLoading").hide();
});
}
setInterval(ajaxRefresh, 1000);
in Index.aspx:
<script type="text/javascript" src="../../Scripts/AjaxRefresh.js"></script>
<div id="AjaxDiv">
<% Html.RenderPartial("Computers", Model, ViewData); %>
</div>
and this in Computers.ascx:
<% Ajax.BeginForm("Index", new { groupName = Model.Name }, new AjaxOptions() { HttpMethod = "Post", LoadingElementId = "AjaxLoading", UpdateTargetId = "AjaxDiv" }, new { id = "AjaxForm" }); Html.EndForm();%>
<%= Ajax.ActionLink("Send", "Index", new { groupName = Model.Name, data="blah" },
new AjaxOptions() { HttpMethod="Post", LoadingElementId="AjaxLoading", UpdateTargetId="AjaxDiv" }) %>
If you click the "Send" link, everything still works, but the page stops refreshing automatically. I've tried subscribing to the ajax events, but Sys.WebForms.PageRequestManager.getInstance() is undefined.