gpt4 book ai didi

javascript - 为 OnSuccess、OnFailure、OnComplete 和 OnBegin 提供回调参数时使用 Ajax.BeginForm 时出错

转载 作者:行者123 更新时间:2023-11-28 12:47:13 26 4
gpt4 key购买 nike

我正在尝试使用 Ajax 表单,每当我向任何 AjaxOptions 属性提供回调方法时,我都会收到此错误。

Microsoft JScript runtime error: Object doesn't support this property or method

如果我不向任何属性(OnSuccess、OnFailure、OnComplete 或 OnBegin)提供回调函数,则不会发生错误并且表单会正确发布。

这是我的代码。

<% using (Ajax.BeginForm("someAction", "SomeController", new AjaxOptions() {
HttpMethod="POST",
UpdateTargetId = "feedbackMsg",
OnSuccess = "ShowConfirmationMessage"
}))
{ %>

我的 JavaScript 代码是这样的。

函数 ShowConfirmationMessage(xhr) {
警报(xhr);}

当我提供 OnSuccess 方法时,代码会像这样呈现。

<form action="/Review/SaveQualityScore" 
method="post"
onclick="Sys.Mvc.AsyncForm.handleClick(this, new Sys.UI.DomEvent(event));"
onsubmit="Sys.Mvc.AsyncForm.handleSubmit(this, new Sys.UI.DomEvent(event),
{
insertionMode: Sys.Mvc.InsertionMode.replace,
httpMethod: &#39;POST&#39;,
updateTargetId: &#39;feedbackMsg&#39;,
onSuccess: Function.createDelegate(this, ShowConfirmationMessage)
});"
>

我猜测 Function.createDelegate 是问题所在。因为当我删除 OnSuccess 属性时, function.CreateDelegate 不会被渲染,并且一切正常。

无论如何,我在这里快要疯了,任何帮助将不胜感激。谢谢!

最佳答案

确保包含以下脚本:

  • MicrosoftAjax.js
  • MicrosoftMvcAjax.js

关于javascript - 为 OnSuccess、OnFailure、OnComplete 和 OnBegin 提供回调参数时使用 Ajax.BeginForm 时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6347784/

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