【发布时间】:2010-08-20 21:17:34
【问题描述】:
我使用 $.ajax() 每 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 中重定向和呈现新视图() 成功回调。我需要从这个轮询 ajax 回发中重定向到“AnotherAction”。 Firebug 的响应是来自“AnotherAction”的视图,但它没有呈现。
【问题讨论】:
标签: asp.net-mvc ajax jquery