JSON删除按钮单击时不满意

时间:2016-10-27 01:16:45

标签: jquery json asp.net-mvc-4 razor

[LogInFilter]
    public JsonResult MemberDelete(Int32 MemID)
    {
        MemberTbl Mem = db.MemberTbls.Where(x => x.ID == MemID).FirstOrDefault();
        db.MemberTbls.Remove(Mem);
        db.SaveChanges();
        return Json(true, JsonRequestBehavior.AllowGet);
    }   

这是我的HTML和Javascript: -

 function DeleteMember(M_ID) {
        if (confirm("Are You Sure Delete Selected Member Record No.? " + M_ID)) {
            var data = { 'ID': M_ID }
            $.post('/Admin/MemberDelete', data,
            function (data) {
                if (data == true)
                    alert("Deleted Successfully!!");
                else
                    alert("Can't Delete. Contact Support Team.");
            });
        }
    }
 format: @<text>
            @Html.Raw("<img src='/images/edit.png' title='Edit' onclick='EditMember(" + item.ID + ")' />")
            @Html.Raw("<img src='/images/delete.png' title='Delete' onclick='DeleteMember(" + item.ID + ")' />")
        </text>

点击DeleteMember我收到消息 '你确定删除了选定的会员记录号吗? “+ M_ID' 然后单击确定单击时出现错误: - POST http://localhost:52422/Admin/MemberDelete 500(内部服务器错误)

0 个答案:

没有答案