title: DataTables: Uncaught TypeError: Cannot read property 'length' of undefined?
body: <p>So, here is my AJAX call for the DataTables table object. I am trying to get the JSON to fill in a table with rows only, as it already has header rows.</p>
  
  <p>I am not clear as to what the syntax of the DataTables ajax calls are, as they differ from one version to the other.</p>
  
  <pre><code>$('#MainContentPlaceHolder_business_return_flights').dataTable({
      "ajax": {
          "url": "Browse.aspx/GetBusinessFlights",
          "type": "POST",
          "contentType": "application/json; charset=utf-8",
          "dataType": "json"
      }
  });
  </code></pre>
  
  <p>I keep getting the error: <code>Uncaught TypeError: Cannot read property 'length' of undefined</code></p>
  
  <p>Here is the JSON being returned:</p>
  
  <pre><code>{
    "d":{
    "draw":"1",
    "recordsTotal":"70",
    "recordsFiltered":"70",
    "aData":[
               [
                  "BI 098",
                  "London (LHR)",
                  "Dubai",
                  "08-08-2014",
                  "12:55 PM",
                  "11:55 PM",
                  "Royal Brunei",
                  "1",
                  "0",
                  "1300",
                  "\u003cbutton type=\"button\" href=\"javascript:void(0)\" onclick=\"selectFlight($(this))\" data-toggle=\"oflight\" class=\"btn btn-block btn-info\"\u003eBook\u003c/button\u003e"
               ],
               [
                  "CY 383",
                  "Dubai",
                  "Larnaca",
                  "08-06-2014",
                  "1:45 PM",
                  "4:05 PM",
                  "Cyprus Airways",
                  "1",
                  "0",
                  "1100",
                  "\u003cbutton type=\"button\" href=\"javascript:void(0)\" onclick=\"selectFlight($(this))\" data-toggle=\"oflight\" class=\"btn btn-block btn-info\"\u003eBook\u003c/button\u003e"
               ]
          ]
      }
  }
  </code></pre>
  
  <p><strong>Update:</strong> Here is my return method:</p>
  
  <pre><code>[WebMethod]
  public static Dictionary&lt;string, object&gt; GetBusinessFlights()
  {
      listRows = new List&lt;List&lt;string&gt;&gt;();
      business = new Table();
      economy = new Table();
  
      FillTable(economy, business, scheduledFlights.List);
  
      foreach (TableRow row in business.Rows)
      {
          listRow = new List&lt;string&gt;();
  
          foreach (TableCell cell in row.Cells)
          {
              listRow.Add(cell.Text);
          }
  
          listRows.Add(listRow);
      }
  
      field = new Dictionary&lt;string, object&gt;() { { "draw", "1" }, { "recordsTotal", economy.Rows.Count.ToString() }, { "recordsFiltered", economy.Rows.Count.ToString() }, { "aData", listRows } };
  
      return field;
  
  }
  </code></pre>
  
  <p><strong>Note:</strong> The <code>FillTable()</code> only fills in the data into the business and economy Table objects.</p>