title: Why does this DataTables Ajax call not work properly?
body: <p>I am attempting to get dataTables plugin to work with information for a website. I have read the <a href="http://datatables.net/release-datatables/examples/data_sources/server_side.html" rel="nofollow noreferrer">documentation</a> and <a href="http://datatables.net/forums/discussion/7949/getting-cannot-read-property-length-of-undefined-in-chrome-error/p1" rel="nofollow noreferrer">various</a> <a href="http://datatables.net/forums/discussion/6101/cannot-read-property-length-of-undefined-with-ajax-source/p1" rel="nofollow noreferrer">support</a> threads for datatables as well as <a href="https://stackoverflow.com/questions/7629423/using-ajax-to-load-a-jquery-datatable">various</a> <a href="https://stackoverflow.com/questions/9566899/jquery-data-tables-server-side-processing-not-working-as-expected">StackOverflow</a> <a href="https://stackoverflow.com/questions/7440184/jquery-datatables-and-initial-data-load">questions</a>, to no avail in resolution. According to the above documentation, the code I have should work just fine... it doesn't. </p>
  
  <p>Javascript:
  </p>
  
  <pre><code>$(document).ready( function(){
   $('#results_table').dataTable( {
    'bServerSide': true,
    'sAjaxSource': 'results.php',
    'fnServerParams': function ( aoData ) {
      aoData.push( { 't': Math.random() }); 
      }
     });
  });
  </code></pre>
  
  <p>HTML Code:
  </p>
  
  <pre><code>&lt;div id='results'&gt;
    &lt;table id='results_table' &gt;
     &lt;thead&gt;
      &lt;tr&gt;
      &lt;th&gt;Num&lt;/th&gt;
      &lt;th&gt;Type&lt;/th&gt;
      &lt;th&gt;Access date&lt;/th&gt;
      &lt;th&gt;Access name&lt;/th&gt;
     &lt;/tr&gt;
    &lt;/thead&gt;
   &lt;tbody&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>PHP snippet (after retrieving/formatting SQL data:
  </p>
  
  <pre><code>$output = array('sEcho'=&gt;1,'iTotalRecords'=&gt;$count, 'iTotalDisplayRecords'=&gt;$count, 'aaData'=&gt; $results);
  echo json_encode($output);
  </code></pre>
  
  <p>Returned data (small subset of the total for testing):</p>
  
  <pre><code>{"sEcho":1,"iTotalRecords":3,"iTotalDisplayRecords":3,"aaData":[["1707052901-1A","D","Aug 17, 2012 1:54 PM","aqr"],["1707052901-1A","C","Aug 17, 2012 1:53 PM","aqr"],["2835602-4A","D","Aug 15, 2012 7:39 AM","aqr"]]}
  </code></pre>
  
  <p>Now, when I load the page with datatables I receive an <em>extremely</em> helpful answer regarding -</p>
  
  <blockquote>
    <p>Uncaught TypeError: Cannot read property 'length' of undefined jquery.dataTables.min.js:49 </p>
  </blockquote>
  
  <p>and the table does not populate with information. </p>
  
  <p><strong>Question:</strong> What am I doing wrong; why does my implementation of server-side processing for dataTables not work?? How can I fix this to display properly?</p>