在ajax中使用url.action的替代方法是什么
例如 我希望在Ajax中有这样的东西,比如:在ajax中使用url.action的替代方法是什么,ajax,url,asp.net-mvc-ajax,Ajax,Url,Asp.net Mvc Ajax,例如 我希望在Ajax中有这样的东西,比如: @url.Action("Actionname", "ControllerName", new { id=@item.id, @class="test"}) 我试过了,但对我没有好处: @Ajax.action("Actionname", "ControllerName",new { id=@item.id, @class="test"}) 有人能帮我吗?在asp.net mvc中,我使用Ajax.net和asp.net @Ajax.Acti
@url.Action("Actionname", "ControllerName", new { id=@item.id, @class="test"})
我试过了,但对我没有好处:
@Ajax.action("Actionname", "ControllerName",new { id=@item.id, @class="test"})
有人能帮我吗?在asp.net mvc中,我使用Ajax.net和asp.net
@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"})
和jqueryajax
@Ajax.BeginForm("Action", "Controller", new AjaxOptions { HttpMethod = "POST", OnSuccess = "successFunction", ... })
{
@Html.HiddenFor(item => item.id)
//etc fields you want to send
}
}))
我想这会对你有所帮助。谢谢你,伙计,但是我应该为每一个动作都这样做吗?有更好的解决方案吗?Sry这么晚了,第一个示例用于巨大的html表单,第二个示例用于发送额外的js数据。所以它使用简单的Url.Action包装在ajax调用中。ps:Url.Action构造一个供使用的链接(字符串Url),您可以在表单、href attr或js stringdon’t matter中使用它,感谢您的努力:)
$.ajax({
url: '@Url.Action("Action", "Controller")',
type: "GET",
data: { 'id': '@item.id' },
success: ...