2013-10-31 3 views
0

Ajax.BeginForm을 사용할 때 문제가 발생했습니다. jquery-1.8.2.min.js를 입력하면 확인 메시지가 표시되지만 ok를 클릭하면 img가 표시됩니다. 값을 삭제하지 않지만 jquery-1.8.2.min.js를 제거하고 img를 클릭하여 메시지 확인을 표시하지 않지만 값을 올바르게 삭제합니다. 오류가있는 곳을 찾을 수 없습니다. 감사합니다. Ajax.BeginForm이 제대로 작동하지 않습니다.

당신이 ID에 의해 직원을 삭제할 때문에 "POST"해야한다 먼저 모든 HttpMethod의 뭔가를 삭제 할 것인지

<script src="@Url.Content("~/Scripts/jquery-1.8.2.min.js")" type="text/javascript">/script> 

<script src="../Scripts/jquery.unobtrusive-ajax.min.js" type="text/javascript" ></script> 

<script src="@Url.Content("~/Scripts/jquery.unobtrusive-ajax.js")" type="text/javascript"></script> 

<script src="@Url.Content("~/Scripts/jquery.validate.js")" type="text/javascript"></script> 

<script src="@Url.Content("~/Scripts/jquery.validate.unobtrusive.js")" type="text/javascript"></script> 



@using (Ajax.BeginForm("Delete", "Employee", new { id = item.EmployeeId },new AjaxOptions 
        {//GetPacients is name of method in EmployeeController 

           Confirm="Are you sure you want to delete this employee?", 
           HttpMethod = "Get", 
           InsertionMode = InsertionMode.Replace, 
           UpdateTargetId = "EnployeeViewTbale", 

        })) 
     { 

      <input type="image" class="deleteImage" src ="Content/Images/delete3.png" /> 


     } 
+0

를 해결한다? –

+0

@ LarsAnundskås 오 죄송합니다 내가 그것을 제거했지만 아직도 해결책을 가지고 : ( – user2939764

답변

1

(우리가 사용하는 데이터를 전송하는 --- 내 코드입니다 POST), 두 번째 ActionResult는 HttpPost로 anotated되어야합니다. 두 번 jquery.unobtrusive-은 ajax.js를 참조 않은 이유

[HttpPost] 
public ActionResult Delete(int id) 
{ 
    //code here 
return RedirectToAction(); 
} 

이것은 당신이 처음에해야 할 것은 다음 더 버그

+0

고마워요 :) – user2939764

관련 문제