在 ajax 中使用 url.action 的替代方法是什么
what is the alternative of using url.action in ajax
例如
@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"})
谁能帮我解决这个问题?
在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
}
和JQueryajax
$.ajax({
url: '@Url.Action("Action", "Controller")',
type: "GET",
data: { 'id': '@item.id' },
success: ...
});
认为它会对你有所帮助。
例如
@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"})
谁能帮我解决这个问题?
在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
}
和JQueryajax
$.ajax({
url: '@Url.Action("Action", "Controller")',
type: "GET",
data: { 'id': '@item.id' },
success: ...
});
认为它会对你有所帮助。