表单序列化总是returns空字符串

Form serialization always returns empty string

我的视图中有一个下拉菜单。基于 selection,我将部分视图插入视图中的 div(占位符)。下面是视图。

<div class="container">
    <div class="row">
    <div class="col-lg-4"><p class="lead">What do you want to do?</p></div>
    <div class="col-lg-8">
        <select id="myDropDown">
            <option id="0" selected>I want to..</option>
            <option id="1">Reset my password</option>
        </select>
    </div>
</div>
<div id="partialPlaceHolder" style="display:none;"> </div>
<script type="text/javascript">
  $(document).ready(function () {
    $('#myDropDown').change(function () {

        /* Get the selected value of dropdownlist */
        var selectedID = $(this).find('option:selected').attr('id');

        /* Request the partial view with .get request. */
        $.get('/Requests/FindPartial/' + selectedID, function (data) {

            /* data is the pure html returned from action method, load it to your page */
            $('#partialPlaceHolder').html(data);
            /* little fade in effect */
            $('#partialPlaceHolder').fadeIn('fast');
        });

    });
});

因此,当我在下拉列表中 select、"Reset my password" 时,我成功地将我的局部视图插入到我视图中的 div 中。以下是我的部分看法。

 @using (Html.BeginForm())
 {
     @Html.AntiForgeryToken()
     <div class="row">
         <div class="col-lg-12">
             <div class="well well-lg" style="text-align:left">
                 <div class="form-horizontal" id="resetpasswordform">
                     <h4>Reset Password</h4>
                     <hr />
                     <div class="form-group">
                         @Html.LabelFor(model => model.ServersList, htmlAttributes: new { @class = "control-label col-md-2" })
                         <div class="col-md-10">
                             @Html.DropDownListFor(model => model.ServerName, new SelectList(Model.ServersList))
                         </div>
                     </div>
                     <div class="form-group">
                         @Html.LabelFor(model => model.UserName, htmlAttributes: new { @class = "control-label col-md-2" })
                         <div class="col-md-10">
                             @Html.EditorFor(model => model.UserName, new { htmlAttributes = new { @class = "form-control" } })
                         </div>
                     </div>
                     <div class="form-group">
                         <div class="col-md-offset-2 col-md-10">
                             <input type="button" id="submitButton" value="Reset" class="btn btn-default" />
                         </div>
                     </div>
                 </div>
             </div>
         </div>
     </div>
 }
 <script>
     $(function () {
         $("#submitButton").click(function () {
             debugger;
             $.ajax({
                 type: "POST",
                 url: "Requests/Do_ResetPassword",
                 data: $("#resetpasswordform").serialize(),
                 success: function (data) {
                     debugger;
                 },
                 error: function (jqXHR, textStatus, errorThrown)
                 {
                     alert(errorThrown);
                 }
             });
         });
     });
 </script>

问题是单击提交按钮时,我进行了 ajax post 调用,$("#resetpasswordform").serialize() 始终为“”(空字符串)。

我试着只用一个元素制作视图。我验证了元素具有 name 属性以便序列化工作。我还确认我的按钮中没有 type=submit。我将 resetpasswordform 更改为一种形式,而不是 div。我什至直接在 Index.cshtml 中渲染了部分视图,而没有动态填充。没有解决问题。一直都是 returns 空字符串。

我在 SO 中验证了所有其他类似的问题,但没有得到任何关于我做错了什么的提示。请帮忙。

在表单标签中设置id怎么样:

@using (Html.BeginForm("action", "controller", FormMethod.Post, new { Id = "resetpasswordform" }))

并将其从 div 中删除。