使用Ajax.BeginForm错误给予了的onSuccess,onFailure处,和的onComplete一个OnBegin回调参数时, [英] Error using Ajax.BeginForm when giving a callback parameter for OnSuccess, OnFailure, OnComplete and OnBegin

查看:1656
本文介绍了使用Ajax.BeginForm错误给予了的onSuccess,onFailure处,和的onComplete一个OnBegin回调参数时,的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试使用Ajax的形式,而每当我提供一个回调方法,任何AjaxOptions属性我得到这个错误。

I'm trying to use an Ajax form, and whenever I provide a callback method to any of the AjaxOptions properties I get this error..

微软JScript运行时错误:对象不支持此属性或方法

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

如果我不向任何属性(的onSuccess,onFailure处,的onComplete或OnBegin)没有出现错误和形式得到正确公布。提供一个回调函数

If I do not provide a callback function to any of the properties (OnSuccess, OnFailure, OnComplete, or OnBegin) no error occurs and the form gets posted correctly.

下面是我的code。

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

我的JavaScript code是这样的。

My javascript code is this.

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

在我提供的onSuccess方法code获取呈现这样。

When I provide the OnSuccess method the code gets rendered like this.

<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没有得到渲染,一切工作正常。

I'm guessing the Function.createDelegate is the problem. Because when I remove the OnSuccess property the function.CreateDelegate doesn't get rendered and everything works fine.

不管怎么说,我要在这里疯狂,任何帮助将是AP preciated。谢谢!

Anyways, I'm going crazy over here, any help would be appreciated. Thank you!

推荐答案

请确保以下脚本都包含:

Make sure the following scripts are both included:


  • MicrosoftAjax.js

  • MicrosoftMvcAjax.js

这篇关于使用Ajax.BeginForm错误给予了的onSuccess,onFailure处,和的onComplete一个OnBegin回调参数时,的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆