아약스 호출로 삭제 작업을 수행 할 수있는 코드를 작성했습니다. C# 코드는 아래와 같습니다.jquery.getJSON() 콜백 함수가 실행되지 않습니다.
function deleteGenre(code) {
$.getJSON("/Administration/Genre/Delete?code=" + code,
function (data) {
if (!data.deleted) {
alert("WARNING - You cannot delete a genre that is currently in use.");
return false;
}
else {
//window.location('/Administration/Genre/Edit');
return false;
}
});
}
을하지만 JQuery와 스크립트를 실행할 때, 콜백 함수는 실행되지 않습니다
[AcceptVerbs(HttpVerbs.Get)]
public JsonResult Delete(Guid code)
{
Genre obj = null;
//TODO : FIX HACK
try
{
obj = Genre.Fetch(code, CurrentUserId, null);
if (obj != null)
obj.Delete(CurrentUserId, null);
}
catch (Exception ex)
{
return Json(new
{
deleted = false
}, JsonRequestBehavior.AllowGet);
}
return Json(new
{
deleted = true
}, JsonRequestBehavior.AllowGet);
}
그럼 내가 사용한 JQuery와해서 getJSON()으로는 다음과 같다. 브라우저 유효 결과 ({ "삭제": 거짓})를 통해 링크 (../Administration/Genre/Delete?code=835e56f0-a339-4da9-8cbb-d93b12a01d37)를 방문했을 때.
이 문제를 어떻게 해결할 수 있습니까? 도와주세요. 미리 감사드립니다.
'/ 관리/장르/삭제를 '와'../ Administration/Genre/Delete'는 같은 위치로 해석되지 않을 수도 있습니다. – Musa
'deleteGenre' 메서드는 어떻게 호출합니까? 이 코드를 추가 할 수 있습니까? – serefbilge