TypeError: aData is undefined

TypeError: aData is undefined

ashiersashiers Posts: 101Questions: 8Answers: 7
edited December 2013 in General
Hi there,

I'm putting together a new example of how we can use Functions within JED to concatenate Strings on the server side prior to sending the data to the client side for DataTables.

Please see online example: http://jed-datatables.ca/jed/examples/functions.html

My HTML looks like this:

[code]

...




Name
Landline Phone





Loading data from server




Name
Landline Phone





[/code]

My JavaScript looks like this:

[code]
$(document).ready(function() {
$('#example').dataTable( {
"sDom": "Tfrtip",
"sAjaxSource": "../jsp/functions.jsp",
"aoColumns": [
{ "mData": "name"},
{ "mData": "phone" }
]
} );
} );
[/code]

I'm returning an Object as a JSON string that looks like this:

[code]
[{"name":"Eunice Abaga","phone":"555-1234"},{"name":"Semali Abdelhak","phone":"555-4321"},{"name":"Susan Abenheimer","phone":"555-5748"},{"name":"Louise Adongo","phone":"555-0932"},{"name":"Sherri Aikenhead","phone":"555-0012"},{"name":"Samantha Aiton","phone":"555-0120"},{"name":"Toyin Akindoju","phone":"555-9122"},{"name":"Sameer Alladina","phone":"555-8112"},{"name":"Ken Allain","phone":"555-7744"},{"name":"Daniel Allen","phone":"555-7141"},{"name":"Mike Campbell","phone":"555-6021"},{"name":"Phil Collins","phone":"555-2234"},{"name":"Peter Finch","phone":"555-0602"},{"name":"Dave MacDonald","phone":"555-6490"},{"name":"Travis McKain","phone":"555-1153"},{"name":"Bill Paxton","phone":"555-1131"},{"name":"Zoie Prentice","phone":"555-3301"},{"name":"Bob Richards","phone":"555-1203"},{"name":"Chris Streeter","phone":"555-8455"},{"name":"Jessie Ventura","phone":"555-1903"},{"name":"Debbie Williams","phone":"555-6645"}]
[/code]

I'm getting a TypeError: aData is undefined

for ( i=0 ; i

Replies

  • tangerinetangerine Posts: 3,365Questions: 39Answers: 395
    A forum search for "TypeError: aData is undefined" would reveal this
    http://datatables.net/forums/discussion/comment/53291
    among others.
  • ashiersashiers Posts: 101Questions: 8Answers: 7
    I was able to fix the problem. Thanks for your input.
  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    How did you resolve it? With the JSON structure you posted, you coulee use sAjaxDataProp to tell DataTables to expect a plain array of data.

    Allan
  • ashiersashiers Posts: 101Questions: 8Answers: 7
    That's precisely how I solved the problem. I added the sAjaxDataProp to my JavaScript:

    $(document).ready(function() {
    $('#example').dataTable( {
    "sDom": "Tfrtip",
    "aaSorting": [ ], // Prevent initial sorting
    "sAjaxSource": "../jsp/functions.jsp",
    "sAjaxDataProp": "",
    "bProcessing": true,
    "aoColumns": [
    { "mData": "name"},
    { "mData": "phone" }
    ]
    } );
    } );
This discussion has been closed.