title: Data Null on Ajax Post
body: <p>I'm learning about ajax to make my life a little easier moving forward. I was able to follow an example and get a constant array to POST to my controller normally.</p>
  
  <p>Now that I am trying to get data from an html form, I get a null array in my controller.</p>
  
  <p>using <code>.serialize()</code> I get <code>[0] = "item=teststring1&amp;item=teststring2"</code></p>
  
  <p>using <code>.serializeArray()</code> I get an array of length 2 (the correct size), with both values null. </p>
  
  <p>I've read about the issues with <code>serializeArray()</code> and how it requires certain tags.</p>
  
  <p>How can I resolve the issue of a null array posting to my controller?</p>
  
  <p>JS</p>
  
  <pre><code>// #EditDate is form id
  var data = $('#EditDate').serializeArray();  
  
          $.ajax({
                  url: '@Url.Action("Index", "TrainingDates")',
                  type: "POST",
                  dataType: "json",
                  data: {'dates' : data},
                  success: function (result) {
                      alert("success" + result);
                  },
                  error: function (result) {
                      alert("failure" + result);
                  }
          });
  
          $(element).val('Edit');
  </code></pre>
  
  <p>HTML</p>
  
  <pre><code>@model List&lt;string&gt;
  @{
      ViewBag.Title = "Dates";
  }
  @using (Html.BeginForm("Index", "TrainingDates", FormMethod.Post, new { @id = "EditDate", @class = "collapse" }))
          {
              foreach (var item in Model)
              {
                  &lt;tr&gt;
                      &lt;td&gt;
                          &lt;input type="button" class="btn btn-primary btn-sm" style="width:inherit" onclick="editable('@item', this)" value="Edit"&gt;
                      &lt;/td&gt;
                      &lt;td&gt;
                              @Html.TextBoxFor(m =&gt; item, new { @id = item, name = item, @class = "form-control", @readonly = "readonly" })
                      &lt;/td&gt;
                  &lt;/tr&gt;
              }
          }
  </code></pre>
  
  <p>Controller</p>
  
  <pre><code>[HttpPost]
  public ActionResult Index(List&lt;string&gt; dates)
  {
          if(dates != null)
          {
              var json = new { success = true };
              return Json(json);
          }
          return Json(false);
   }
  </code></pre>