Not able to read data from text file in JSOn Format
Not able to read data from text file in JSOn Format
sapleshailesh
Posts: 1Questions: 0Answers: 0
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"
}
]
}
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"
}
]
}
This discussion has been closed.
Replies
Allan