2012-01-12 6 views
0

목록보기에서 Ajax를 사용하여 삭제를 시도하고 컨트롤러 메소드에 "Delete (Ajax)"버튼을 누르면 오류가 발생합니다 :mvc3에서 ajax가있는 행을 삭제합니다.

The resource cannot be found. Description: HTTP 404. The resource you are looking for (or one of its dependencies) could have been removed, had its name changed, or is temporarily unavailable. Please review the following URL and make sure that it is spelled correctly. Requested URL: /Idea/DeleteAjax/30

아이디어가 있으십니까?

//controller 

     [HttpPost] 
     public ActionResult DeleteAjax(int id) 
     { 
      IdeeRepository ideeRepo = new IdeeRepository(); 

      WIKIIDEE idee = new WIKIIDEE(); 
      idee = ideeRepo.GetIdeeByID(id); 

      ViewModels.AjaxResponseVM ajaxVM; 

      try 
      { 
       ideeRepo.DeleteIdea(idee); 
       ideeRepo.SaveIdea(); 

       ajaxVM = new ViewModels.AjaxResponseVM(Convert.ToInt32(idee.ID), "Idee eliminato con successo!"); 
      } 
      catch 
      { 
       ajaxVM = new ViewModels.AjaxResponseVM(-1, "Error!"); 
      } 

      return Json(ajaxVM); 
     } 

//보기

@Ajax.ActionLink("Elimina Idea(Ajax)", "DeleteAjax", "Idea", new { id = ViewBag.Ideas[i].ID }, new AjaxOptions { Confirm = "Are you sure!", OnSuccess = "DeleteResponse", HttpMethod = "POST" }) 

답변

0

다음과 같은 파일을 참조하고 있는지 확인하십시오 :

<script src="@Url.Content("~/Scripts/MicrosoftAjax.js")" type="text/javascript"></script> 
<script src="@Url.Content("~/Scripts/MicrosoftMvcAjax.js")" type="text/javascript"></script> 
<script src="@Url.Content("~/Scripts/jquery.unobtrusive-ajax.js")" type="text/javascript"></script> 
관련 문제