解决方法
在电影控制器中删除HTTPPost操作方法
[HttpPost] public ActionResult Delete(int id) { try { repo.DeleteMovie(id); return "deleted" } catch(Exception ex) { //Log errror } return "Failed"; }
在你的视图中,
<a href="#" data-movieId="34" class="movie">Delete Avengers</a> <a href="#" data-movieId="35" class="movie">Delete Iron Man</a> <script type="text/javascript"> $(function(){ $(".movie").click(function(e){ e.preventDefault(); $.post("@Url.Action("Delete","Movie")",{ id : $(this).data("movieId")},function(data){ alert(data); }); }); }); </script>