title: jQuery DataTables: Uncaught TypeError: Cannot read property 'length' of undefined
body: <p>Code: On click of the submit button, once users enter the text, the application hits the rest API which has data in the format of JSON.The code should process the JSON data and from a jquery data table.</p>
  
  <pre><code>$(document).ready(function() {
                  $('#txt').click(function () {
                      var requestData = $('#txtid').val();
                      var url = '&lt;my api url&gt;' + requestData;
                      $('#resultDiv1').dataTable({
                          "processing": true,
                          "ajax": url,
                          "columns": [
                              {"": "account.id"},
                              {"": "account.rel"},
                              {"": "account.fin"},
                              {"": "account.date"}
                          ],
                          "dom": "Bfrtip",
                          "buttons": [
                              'copy', 'csv', 'excel', 'pdf', 'print'
                          ]
                      });
                  });
              });
  </code></pre>
  
  <p>I am trying to form a Jquery data table from a restful API but getting the below error:</p>
  
  <pre><code>Uncaught TypeError: Cannot read property 'length' of undefined
              at jquery.dataTables.min.js:48
              at i (jquery.dataTables.min.js:35)
              at Object.success (jquery.dataTables.min.js:35)
              at fire (jquery-1.12.4.js:3232)
              at Object.fireWith [as resolveWith] (jquery-1.12.4.js:3362)
              at done (jquery-1.12.4.js:9840)
              at XMLHttpRequest.callback (jquery-1.12.4.js:10311)
  </code></pre>
  
  <p>Ajax Response: Here is the format of Ajax coming from RestAPI:</p>
  
  <pre><code>  {
        "account": [
          {
            "id": "1", 
            "rel": "P", 
            "fin": "abc", 
            "date": "2001-01-05"
          }, 
          {
             "id": "2", 
            "rel": "P", 
            "fin": "def", 
            "date": "2001-02-05"
          }, 
          {
            "id": "3", 
            "rel": "R", 
            "fin": "ghi", 
            "date": "2019-01-05"
          }
        ]
      }
  </code></pre>
  
  <p>Can someone please throw light on why this is coming and what changes do I need to make? </p>