Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8417395
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T02:02:01+00:00 2026-06-10T02:02:01+00:00

I am attempting to get dataTables plugin to work with information for a website.

  • 0

I am attempting to get dataTables plugin to work with information for a website. I have read the documentation and various support threads for datatables as well as various StackOverflow questions, to no avail in resolution. According to the above documentation, the code I have should work just fine… it doesn’t.

Javascript:

$(document).ready( function(){
 $('#results_table').dataTable( {
  'bServerSide': true,
  'sAjaxSource': 'results.php',
  'fnServerParams': function ( aoData ) {
    aoData.push( { 't': Math.random() }); 
    }
   });
});

HTML Code:

<div id='results'>
  <table id='results_table' >
   <thead>
    <tr>
    <th>Num</th>
    <th>Type</th>
    <th>Access date</th>
    <th>Access name</th>
   </tr>
  </thead>
 <tbody>
</div>

PHP snippet (after retrieving/formatting SQL data:

$output = array('sEcho'=>1,'iTotalRecords'=>$count, 'iTotalDisplayRecords'=>$count, 'aaData'=> $results);
echo json_encode($output);

Returned data (small subset of the total for testing):

{"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"]]}

Now, when I load the page with datatables I receive an extremely helpful answer regarding –

Uncaught TypeError: Cannot read property ‘length’ of undefined jquery.dataTables.min.js:49

and the table does not populate with information.

Question: 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?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T02:02:03+00:00Added an answer on June 10, 2026 at 2:02 am
    aoData.push( { 't': Math.random() }); 
    

    should be used like this:

    aoData.push( { 'name': 't', 'value':Math.random() }); 
    

    not sure if this is the issue, but this fixed some of my problems when using datatables

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Attempting to get Spring internationalization working. I have used classpath:messages basename, created .properties files
Im attempting to get a block of text from a file I have already
I am attempting to get rails routes paths via nested resources. I have looked
I have been attempting to get log4net logging in my asp.net web application with
I am attempting to get a MVC 3 generated 'Create' page to have all
I have been attempting to get log4net logging any info or error into my
I'm attempting to get the following site to work: The Test logo appears properly
I am attempting to get the information from one table (games) and count the
I am attempting to get a list of items along with the order information
I am attempting to get django working using pypy. I have everything setup and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.