title: How to reload Datatable using Ajax when checkbox is clicked
body: <p>I want to be able to reload my Datatable once my checkbox is clicked , provided below is my attempted code but I continue to get error:Uncaught TypeError: Cannot set property 'data' of null not really sure how to handle this error. I have provided both the javascript and the view in my MVC application please let me know if you need more details.</p>
  
  <p><strong><em>.js</em></strong></p>
  
  <pre><code>function ReloadTable()
  {
  
  
      $(document).ready(function () {
          var table =  $('#DashboardTable').DataTable({
  
              "processing": true, // for show progress bar
              "serverSide": true, // for process server side
              "filter": true, // this is for disable filter (search box)
              "orderMulti": false, // for disable multiple column at once
              //"pageLength": 5,
  
  
              "ajax": {
                  "url": "/Chargeback/Index",
                  "type": "GET",
                  "datatype": "json"
              },
              "columns": [
              { "data": "ChargebackCode" },
              { "data": "StatusName" },
              { "data": "BusinessUnitName" },
              { "data": "InvoiceCode" },
              { "data": "OrderCode" },
              { "data": "PickTicketCode" },
              { "data": "CustomerPo" },
              { "data": "AssignedDepartment" },
              { "data": "DivisionName" },
              { "data": "Customer" },
              { "data": "WarehouseName" },
              { "data": "Coordinator" },
              { "data": "ChargebackDate" },
              { "data": "ModDate" },
              { "data": "ChargebackDeadline" },
              { "data": "ChargebackCloseDate" },
              { "data": " DaysOpen" },
              { "data": "ChargebackAmount" },
              { "data": "ChargebackBalance" },
              { "data": "FaultName" },
              { "data": "ResponsibleName" }
              ]
  
          });
          table.ajax.reload();
      });
  
  }
  </code></pre>
  
  <p><strong><em>view:</em></strong></p>
  
  <pre><code>@using (Html.BeginForm("Index", "Chargeback"))
  {
     &lt;label id = "Include" &gt; @Html.CheckBox("IncludeClosed", (bool)ViewBag.IncludeClosed, new { onChange = "ReloadTable()" }) Include Closed&lt;/label&gt;
  
  &lt;table id="DashboardTable" class="table table-striped" &gt;
      &lt;thead&gt;
          &lt;tr&gt;
              &lt;th&gt;Code&lt;/th&gt;
              &lt;th&gt;Status&lt;/th&gt;
              &lt;th&gt;Business&lt;/th&gt;
              &lt;th&gt;Invoice&lt;/th&gt;
              &lt;th&gt;Order&lt;/th&gt;
              &lt;th&gt;Pick Tickets&lt;/th&gt;
              &lt;th&gt;Customer PO&lt;/th&gt;
              &lt;th&gt;Assigned&lt;/th&gt;
              &lt;th&gt;Division&lt;/th&gt;
              &lt;th&gt;Customer&lt;/th&gt;
              &lt;th&gt;Warehouse&lt;/th&gt;
              &lt;th&gt;Coordinator&lt;/th&gt;
              &lt;th&gt;Open Date&lt;/th&gt;
              &lt;th&gt;Last Activity&lt;/th&gt;
              &lt;th&gt;Deadline&lt;/th&gt;
              &lt;th&gt;Closed Date&lt;/th&gt;
              &lt;th&gt;Days Open&lt;/th&gt;
              &lt;th&gt;Amount&lt;/th&gt;
              &lt;th&gt;Balance&lt;/th&gt;
              &lt;th&gt;Fault&lt;/th&gt;
              &lt;th&gt;Responsible&lt;/th&gt;
          &lt;/tr&gt;
      &lt;/thead&gt;
      &lt;tbody&gt;
          @foreach (var item in Model)
          {
              var chargebackDeadline = item.ChargebackDeadline == null ? "" : ((DateTime)item.ChargebackDeadline).ToString("MM/dd/yyyy");
              var chargebackCloseDateAsString = item.ChargebackCloseDate == null ? "" : ((DateTime)item.ChargebackCloseDate).ToString("MM/dd/yyyy");
  
              &lt;tr&gt;
                  &lt;td&gt;@Html.ActionLink(item.ChargebackCode, "Details", "Chargeback", new { id = item.Id }, null)&lt;/td&gt;
                  &lt;td&gt;@item.StatusName&lt;/td&gt;
                  &lt;td&gt;@item.BusinessUnitName&lt;/td&gt;
                  &lt;td&gt;@item.InvoiceCode&lt;/td&gt;
                  &lt;td&gt;@item.OrderCode&lt;/td&gt;
                  &lt;td&gt;@item.PickTicketCode&lt;/td&gt;
                  &lt;td&gt;@item.CustomerPo&lt;/td&gt;
                  &lt;td&gt;@item.AssignedDepartment&lt;/td&gt;
                  &lt;td&gt;@item.DivisionName&lt;/td&gt;
                  &lt;td&gt;@item.Customer&lt;/td&gt;
                  &lt;td&gt;@item.WarehouseName&lt;/td&gt;
                  &lt;td&gt;@item.Coordinator&lt;/td&gt;
                  &lt;td&gt;@item.ChargebackDate.ToString("MM/dd/yyyy")&lt;/td&gt;
                  &lt;td&gt;@item.ModDate.ToString("MM/dd/yyyy")&lt;/td&gt;
                  &lt;td&gt;@chargebackDeadline&lt;/td&gt;
                  &lt;td&gt;@chargebackCloseDateAsString&lt;/td&gt;
                  &lt;td&gt;@item.DaysOpen&lt;/td&gt;
                  &lt;td&gt;$@item.ChargebackAmount&lt;/td&gt;
                  &lt;td&gt;$@item.ChargebackBalance&lt;/td&gt;
                  &lt;td&gt;@item.FaultName&lt;/td&gt;
                  &lt;td&gt;@item.ResponsibleName&lt;/td&gt;
              &lt;/tr&gt;
          }
      &lt;/tbody&gt;
  &lt;/table&gt;
  }
  </code></pre>