今、私はMVCのAjax実装について学んでいますが、正しく動作させるには問題があります。 2つのコントローラメソッドAjax.ActionLinkに失敗しました
@Ajax.ActionLink("Click here to get a title", "Yo",
new AjaxOptions { OnSuccess = "alert(\"YES!\")", OnFailure = "alert(\"WHY?!\")" })
をそして、ここにある:ここで私が持っているものだ
public PartialViewResult GetThatTitle()
{
var titular = new TitleDataEntity { };
titular.TitleName = "Inception!";
titular.PublishDate = DateTime.Now;
titular.Id = 2;
return PartialView("_testView", titular);
}
public JsonResult Yo()
{
var titular = new TitleDataEntity { };
titular.TitleName = "Inception!";
titular.PublishDate = DateTime.Now;
titular.Id = 2;
if(Request.IsAjaxRequest())
{
return Json(titular);
}
return Json(titular);
}
私は関数を呼び出す「ヨ」、ブラウザが私に与え、「WHYを!」警告ボックス。しかし、GetThatTitleを呼び出すと、それは私に成功の警告を与えます。なぜ私はJsonの結果を返すと失敗するのですか?
男、私はばかだと感じます。ヘルプと迅速な返信に感謝します。あなたは揺れる。 – user558594