如何从ActionLink单击来调用Ajax

时间:2018-11-09 02:08:08

标签: jquery ajax razor model-view-controller

我试图在动作链接点击上运行Ajax,但我不知道为什么脚本不会在点击时触发

HTML / Razor

@Html.ActionLink(" ", "DeleteRecord", new { id = item.JPAppId }, new { @class = "fa fa-trash", id = "myLink" })

JQuery / Ajax

<script type="text/javascript">
$("#myLink").click(function (event) {
    event.preventDefault();
    $.ajax({
        url: 'JPApplications/StudentIndex',
        data: { id: $(this).data('id') },
        success: function () {
            alert("Value Deleted");  
        }
    });
});

0 个答案:

没有答案