1

例如

@url.Action("Actionname", "ControllerName", new { id=@item.id, @class="test"})

我在 Ajax 中想要这样的东西,就像这样:

@Ajax.action("Actionname", "ControllerName",new { id=@item.id, @class="test"})

我试过这个,但它对我没有好处:

  @Ajax.ActionLink(".", "DeleteCountry", "Main", new AjaxOptions { HttpMethod = "Post", InsertionMode = InsertionMode.Replace, UpdateTargetId = "Details" }, new { CountryID =  item.CountryID , @class="fa fa-times"}) @Ajax.ActionLink(".", "EditCountry", "Main", new AjaxOptions { HttpMethod = "POST", InsertionMode = InsertionMode.Replace, UpdateTargetId = "Details" }, new {CountryID=item.CountryID,@class="fa fa-pencil"})

任何人都可以帮助我吗?

4

1 回答 1

2

在 asp.net mvc 中我同时使用 Ajax.BeginForm

 @Ajax.BeginForm("Action", "Controller", new AjaxOptions { HttpMethod = "POST",        OnSuccess = "successFunction", ... })
{
    @Html.HiddenFor(item => item.id)
    //etc fields you want to send
}

和 JQuery ajax

$.ajax({
url: '@Url.Action("Action", "Controller")',
        type: "GET",
data: { 'id': '@item.id' },
        success: ... 

});

认为它会帮助你。

于 2016-07-26T14:39:31.847 回答