开发者

MVC Ajax.Beginform OnComplete/OnSuccess fired before controller call

I'm trying to clear an ajax form after an item has been added to the database however the OnComplete and OnSuccess AjaxOptions get called before the form is submitted. How can I get it so the form is submitted first and the the OnComplete is called.

<% using (Ajax.BeginForm("AddTable", new AjaxOptions
                                        {
                                            UpdateTargetId = "tables",开发者_如何转开发
                                            InsertionMode = InsertionMode.InsertAfter,
                                            OnComplete = "ClearForm()"
                                        }))
   {%>

which calls

function ClearForm() {
        $('#DisplayName').val('');
    }

However the DisplayName textbox is cleared before the balue is sent to the controller the form submits to. Is there a way around this.


OnComplete = "ClearForm()" should be called without the parentheses, i.e. OnComplete = "ClearForm". I can't say for sure that it would fix your issue though.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜