나는 액션 방법을 5 초마다 폴링 $ 아약스()를 사용
$.ajax({
type: 'GET', url: '/MyController/IsReady/1',
dataType: 'json', success: function (xhr_data) {
if (xhr_data.active == 'pending') {
setTimeout(function() { ajaxRequest(); }, 5000);
}
}
});
과 ActionResult 조치 :
public ActionResult IsReady(int id)
{
if(true)
{
return RedirectToAction("AnotherAction");
}
return Json("pending");
}
내가에서 ActionResult 할 작업의 반환 형식을 변경했다 RedirectToAction (원래는 JsonResult 였고 나는 Json(new { active = 'active' };
을 반환했습니다.)을 사용하려고했지만 $ .ajax() success 콜백 내에서 새 View를 리디렉션하고 렌더링하는 데 문제가있는 것처럼 보입니다. 이 폴링 아약스 포스트 백에서 "AnotherAction"으로 리디렉션해야합니다. Firebug의 응답은 "AnotherAction"의보기이지만 렌더링이 아닙니다.
다른 게시물에 비슷한 발견 철저한 검색 후. 차이점은 대신 window.location.replace를 사용한다는 것입니다. 감사! –