gpt4 book ai didi

asp.net-mvc - 如何将参数传递给 ASP.NET MVC 中 AjaxOptions 类的 OnSuccess 函数?

转载 作者:行者123 更新时间:2023-12-02 02:55:44 26 4
gpt4 key购买 nike

如何将参数传递给 ASP.NET MVC 中 AjaxOptions 类的 OnSuccess 函数?

这是我的代码,但它不起作用:

<%= Ajax.ActionLink("Delete", 
"Delete",
"MyController",
New With {.id = record.ID},
New AjaxOptions With
{
.Confirm = "Delete record?",
.HttpMethod = "Delete",
.OnSuccess = "updateCount('parameter')"
})
%>
<小时/>

更新

OnSuccess 属性设置为 (function(){updateCount('parameter');}) 解决了我的问题:

<%= Ajax.ActionLink("Delete", 
"Delete",
"MyController",
New With {.id = record.ID},
New AjaxOptions With
{
.Confirm = "Delete record?",
.HttpMethod = "Delete",
.OnSuccess = "(function(){updateCount('parameter');})"
})
%>

最佳答案

您应该能够使用 jQuery 选择器从页面中的字段填充值:

<%= Ajax.ActionLink("Delete", 
"Delete",
"MyController",
New With {.id = record.ID},
New AjaxOptions With
{
.Confirm = "Delete record?",
.HttpMethod = "Delete",
.OnSuccess = "updateCount($('#SomeField).val()))"
})
%>

另请查看此处:Can I pass a parameter with the OnSuccess event in a Ajax.ActionLink

关于asp.net-mvc - 如何将参数传递给 ASP.NET MVC 中 AjaxOptions 类的 OnSuccess 函数?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2608317/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com