代码之家  ›  专栏  ›  技术社区  ›  gfrizzle

AJAX对Submit按钮和this.form.Submit的行为不同?

  •  0
  • gfrizzle  · 技术社区  · 17 年前

    <AcceptVerbs(HttpVerbs.Post)> _
    Function TestAction(ByVal id As Integer) As ActionResult
        Return Content(id)
    End Function
    

    <script type="text/javascript" src='<%= Url.Content("~/Scripts/MicrosoftAjax.debug.js") %>'></script>
    <script type="text/javascript" src='<%= Url.Content("~/Scripts/MicrosoftMvcAjax.debug.js") %>'></script>
    
    <% Using Ajax.BeginForm("TestAction", New AjaxOptions With {.UpdateTargetId = "test"})%>
    <%=Html.Hidden("id", 123)%>
    <%=Html.DropDownList("actions", Nothing, New With {.onchange = "this.form.submit();"})%>
    <input type="submit" value="Submit" />
    <span id="test"></span>
    <% End Using%>
    

    2 回复  |  直到 13 年前
        1
  •  1
  •   Craig Stuntz    17 年前

    the HTML that Ajax.BeginForm generates

    Sys.Mvc.AsyncForm.handleSubmit(
             this,
             new Sys.UI.DomEvent(event),
             { 
                 insertionMode: Sys.Mvc.InsertionMode.replace,
                 updateTargetId: 'test' 
             });
    
        2
  •  0
  •   Ethan Turk    12 年前

    不要使用javascript,而是使用jQuery。刚刚遇到这个问题,它工作得很好。

    this.form.submit()

    $("form").submit() <----jQuery