Cannot read property 'length' of undefined

Cannot read property 'length' of undefined

cyberfunkrcyberfunkr Posts: 1Questions: 0Answers: 0
edited September 2013 in DataTables 1.9
I've seen this question a few times, but none of the fixes suggested fix my problem, so hopefully someone here can see what is missing.

HTML: [code]


Country
ISO2
ISO3
Capital
Currency
Population





[/code]

JS: [code]
$(document).ready(function() {
var oTable = $('#myTable').dataTable({
"bProcessing": true,
"bServerSide": true,
"sAjaxSource": "/ajax.txt",
"aoColumns": [
{ "mData": "country" },
{ "mData": "iso2" },
{ "mData": "iso3" },
{ "mData": "capital" },
{ "mData": "currency" },
{ "mData": "population" },
{ "mData": "mapreference" }
]
});
});

[/code]

AJAX: There are really 227 results, but I'm only showing a few to show format
[code]{
"iTotalRecords": 227,
"aadata": [
{
"capital":"Kabul",
"country":"Afghanistan",
"currency":"Afghani",
"iso2":"AF",
"iso3":"AFG",
"mapreference":"Asia",
"population": 26813057
},
{
"capital":"Tirana",
"country":"Albania",
"currency":"Lek",
"iso2":"AL",
"iso3":"ALB",
"mapreference":"Europe",
"population": 3510484
},
{
"capital":"Algiers",
"country":"Algeria",
"currency":"Algerian Dinar",
"iso2":"DZ",
"iso3":"DZA",
"mapreference":"Africa",
"population": 31736053
},
{
"capital":"Pago Pago",
"country":"American Samoa",
"currency":"US Dollar",
"iso2":"AS",
"iso3":"ASM",
"mapreference":"Oceania",
"population": 67084
}
]
}[/code]

But I still get the length of unknown error. Can someone point out what I'm missing? Thanks

Replies

  • allanallan Posts: 63,498Questions: 1Answers: 10,470 Site admin
    > "aadata"

    Should be `aaData` . You can change the parameter DataTables looks for using sAjaxDataProp .

    Allan
This discussion has been closed.