我似乎无法找出正确的语法。似乎已经尝试了一切:
@model User
...
@Ajax.ActionLink("Add", "AddUser",new {id = Model.Id }, new AjaxOptions
{
HttpMethod = "post",
InsertionMode = InsertionMode.Replace,
UpdateTargetId = "dialog-add-user",
OnSuccess = **"function(){ AddUserShow(" + @Model.Id + ");}",**
OnFailure = "userFailure"
}
成功后,我只需将我的 userId 传递给另一个 Javascript 方法。似乎没有任何效果。我环顾四周,找到了一些建议,但仍然没有运气。我试过:
"new Function('AddUserShow(" + @Model.Id + ")')",
"function(){ AddUserShow(" + @Model.Id + ");}",
"function(){ AddUserShow(this," + @Model.Id + ");}",
Also tried sticking the user ID in a hidden field to try and pass it later from functions above instead of accessing @Model:
"AddUserShow($('#Id').val()))",
接收端代码:
function AddUserShow(id)
{
alert(id);
}
如果重要的话,正在传递的 ID 是一个 Guid。
有任何想法吗 ?提前致谢