E.g。
@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"})
有人可以帮助我吗?
答案 0 :(得分:1)
在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: ...
});
认为它会对你有帮助。