我正在尝试通过 Ajax 执行 DELETE(首选)或 POST。
$(document).ready(function () {
$("a.deleteOne").click(function () {
var id = $(this).parents('td:first').children('.hiddenId').val();
var title = $(this).parents('tr:first').children('td:first').text();
if (confirm("Really delete the [" + title + "] document?")) {
$.ajax({
type: "POST",
url: "/WebApp/Area/Documents/Delete/" + id,
//data: { id: id },
success: function () { alert("Document [" + title + "] deleted."); },
failure: function () { alert("Document [" + title + "] was NOT deleted."); }
});
}
});
return false;
});
由于某种原因,控制器的操作没有被调用。
Action code looks like:
[ValidateAntiForgeryToken]
[Transaction]
[AcceptVerbs(HttpVerbs.Post)]
//[AcceptVerbs(HttpVerbs.Delete)]
public ActionResult Delete(int id)
{
if (!BaseAuthorizationProvider.HasPermissionToPerform(App.Core.Security.Operations.CreateDocumentTask))
{
HandlePermissionException();
}
ActionConfirmation deleteConfirmation = DocumentManagementService.Delete(id);
TempData[ControllerEnums.GlobalViewDataProperty.PageMessage.ToString()] = deleteConfirmation.Message;
return RedirectToAction("Index");
}
我错过了什么?