【发布时间】:2012-04-26 20:18:04
【问题描述】:
我似乎无法找出正确的语法。似乎什么都试过了:
@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。
有什么想法吗? 提前致谢
【问题讨论】:
标签: c# javascript jquery ajax model-view-controller