-1
製品の編集ページを開きたいが、インデックスアクションの後にリストページからそのページにリダイレクトされない。ここでは、私のコードを見つけることができます:私のリスト]ページmvc razorは動作後にURLにリダイレクトしません
:
function getProductDetail(id) {
$.ajax({
type: "POST",
url: '@Url.Action("Index","ProductDetail")',
dataType: "html",
data: JSON.stringify({ "productId": id }),
contentType: "application/json",
success: function (result) {
}
});
}
</script>
そして、私のProductDetailController上:上記のコメントを1として
public ActionResult Index(int productId)
{
Product prod = GetProductDetail(productId);
return View(prod);
}
なぜあなたはajaxコールを行っていますか?リダイレクト – Shyju
@Shyju、jut like? window.location.href = "@ Url.Action(" GetProductDetail "、" ProductDetail "、id。)";しかしその時、idをパラメータとして渡すことができませんでした。 – cagin
はいいいえ.window.location.href = '@ Url.Action( "GetProductDetail"、 "ProductDetail")?productId =' + id'、 – Shyju