这里是我的视图中的ASP MVC代码。它触发关闭控制器并将由assetid和relationshipContext:使用Ajax防止回传的HTML.ActionLink到控制器
@Html.ActionLink("Archive", "Archive", new { assetId = Model.ID, relationshipContext = assetTypeRelation.RelationshipContextID }, new { @class = "btn btn-mini btn-warning", id = "btnArchive" })
我想利用Ajax和这个HTML.ActionLink,但我有点困惑。这里是我开始使用的jQuery。基本上我只需要这个actionlink将assetId和relationshipContext传递给我的assetcontroller中的Archive方法。
$('#btnArchive').click(function(){
$.ajax({
url: '@Url.Action("Archive", "Archive")',
type: 'POST',
dataType: 'json',
data: {
assetId: $(this).attr("assetId"),
relationshipContext: $(this).attr("relationshipContext"),
},
success: function(){
alert("success")
},
error: function() {
alert("error")
},
});
我没有认出顶部的那种语言。我做了一次Google搜索,发现它是asp.net的一部分,特别是mvc的一部分。我添加了asp.net-mvc标签,但是您可能想向代码添加一些解释。 – 2013-02-28 21:31:00
你想混合服务器和客户端代码。 – gdoron 2013-02-28 21:33:06
感谢您添加额外的标记,我更新了我的问题的正文。 – einsteinix 2013-02-28 21:36:16