You can do this with 2 action methods and a javascript timer
[HttpPost] public JsonResult StartProcess() { StartTheMachine(); return new JsonResult() { Data = "Started" }; } [HttpGet] public JsonResult GetProcessUpdate() { return new JsonResult() { Data = GetUpdate(), JsonRequestBehavior = JsonRequestBehavior.AllowGet }; }
and in your opinion something like this:
$.post("<%=Url.Action("StartProcess") %>", function(data) { // do something with data "Started" and start timer setTimeout(GetUpdate, 5000); }); function GetUpdate() { $.get("<%=Url.Action("GetUpdate") %>", function(data) { if (data.Complete) // or some way to tell it has finished { // do something with other data returned } else { // call again if not finished setTimeout(GetUpdate, 5000); } }); }
source share