Not able to read data from text file in JSOn Format

Not able to read data from text file in JSOn Format

sapleshaileshsapleshailesh Posts: 1Questions: 0Answers: 0
edited May 2013 in Editor
Hi ,
I am not able to read data from my txt file and display on to the table column. I am getting "DataTables warning: Added data does not match known number of columns" this error message everytime i load my page.
I am Using below code. Any help would be highly appreciated. Thanks.


$(document).ready(function () {
$("#updateEmail").dataTable( {
"bPaginate": false,
"bFilter": false,
"sAjaxSource": "aa.txt",
"aoColumns": [
{ "sTitle": "Country" ,
"sType" : "title-string",
"sWidth": "20%",
"mData":"Country"
}
] ,
"fnServerData" : function(sSource, aoData, fnCallback) {
/* aoData.push( { "name": "Country", "value": "US" } ); */
$.ajax({
"dataType" : 'json',
"type" : "GET",
"url" : sSource,
"data" : aoData,
"success" :function(json)
{
fnCallback(json);

}
});
}



});
});


$(document).ready(function() {
// Create the form
editor = new $.fn.dataTable.Editor( {
/* "ajaxUrl": "aa.txt", */
"domTable": "#updateEmail",
"fields": [ {
"label": "Country",
"name": "Country"
}
]
} );

// Edit record
$('#updateEmail').on('click', 'a.editor_edit', function (e) {
e.preventDefault();
editor.edit(
$(this).parents('tr')[0],
'Edit record',
{ "label": "Update", "fn": function () { editor.submit() } }
);
} );

});


//HTML Table







//aa.txt files contents

{
"aaData": [
{
"Country": "US"
}

]
}

Replies

  • allanallan Posts: 63,534Questions: 1Answers: 10,475 Site admin
    Can you link use to the page please? The error means just what it says - the number of columns found in the fnAddData is different from the number in the table. To say why that is, we'd need a test case.

    Allan
This discussion has been closed.