보기 재후 데이터를 다른 작업에
[HttpPost]
public ActionResult PostingData(int id, string prezime)
{
//some code
return Json(new { redirect = Url.Action("Create") });
}
TNX를이 코드는 내 문제 해결
보기 재후 데이터를 다른 작업에
[HttpPost]
public ActionResult PostingData(int id, string prezime)
{
//some code
return Json(new { redirect = Url.Action("Create") });
}
TNX를이 코드는 내 문제 해결
대신 리디렉션을, 반환되는 AJAX 요청은 처리 할 수 없습니다. URL을 JSON으로 반환하고 게시물 처리기가 위치를 변경하도록합니다.
$.post("/jQueryPost/PostingData", { id: id, prezime: prezime }, function(data) {
location = data.url;
});
[HttpPost]
public ActionResult PostingData(int id, string prezime)
{
//some code
return Json(new { url = Url.Action("Create") });
}
리디렉션이 작동하지 않는 이유는 비동기 요청을하기 때문입니다. 리다이렉션 코드를 포함하는 응답은 success 메소드에 대한 데이터로 반환되며, 여기서이를 무시합니다.
대신에, 당신이 페이지에있는 양식을 게시 :
$('#example').attr('action', '/jQueryPost/PostingData/').submit();
컨트롤러를
public ActionResult DeleteMenuItem(int id)
{
_menuService.DeleteMenuItemById(id);
return Json(new { url = Url.Action("Index","Menu") }, JsonRequestBehavior.AllowGet);
}
보기
$.getJSON("/Menu/DeleteMenuItem", { id: parseInt(id)}, function(data) {
location = data.url;
});
당신이 당신의 양식을 게시 자바 스크립트를 사용해야하는 이유 ? –
[이 질문] (http://stackoverflow.com/questions/2903685/jquery-preventing-redirecttoaction-from-working)을보십시오. – silent