因爲我是jquery的新手,你能告訴我如何將頁面重定向到另一個動作方法嗎? 我開發了一個MVC web應用程序。我使用jquery post方法做一些驗證,當它返回true時,它會將頁面重定向到另一個。 我的問題是..當我使用window.location重定向頁面時,它在IE(IE 9)中運行良好。但在firefox & chrome上沒有工作。 所以,我嘗試使用jquery post方法在控制器中重定向來自操作方法的頁面。我在jquery post回調中調用重定向post方法。 這是我的代碼:在另一個回調函數中創建一個嵌套的jQuery文章?
$.post(posturl, formData, function (result) {
if (result == 'True') {
$.post("/Controller/RedirectMethod", {_Action: 'Index', _Controller: 'Home'}, null);
}
else
alert('failed');
}
);
,這是我RedirectMethod:
[HttpPost]
public ActionResult RedirectMethod(string _Action, string _Controller)
{
return RedirectToAction(_Action, _Controller);
}
所以我應該怎麼建立在另一篇文章回調嵌套帖子? 還是有另一種重定向頁面的方法?
感謝,
'window.location' should work;你在做什麼? – 2011-05-10 03:26:50
嗯...感謝Alpert,我嘗試使用location.href,它在mozilla和chrome中都有效。但我不知道爲什麼window.location不適合我。 – 2011-05-10 04:57:41