Mohan Srinivas

Mohan Srinivas

  • NA
  • 147
  • 52.5k

table displaying [object Object] in every cell

May 19 2017 6:50 AM
based on drop down i m displaying table using ajax jquery call.while i m selecting drop down list table is displaying but every cells showing [object Object] instead of data's
 
This my jquery code: 
 
function generateTable(json) {
var $table = $('#tblDynamic');
$table.find('thead').empty()
$table.find('tbody').empty()
if (json && json.length > 0) {
var header = json[0];
var columns = [];
for (var col in header) {
columns.push('<th>' + col + '</th>');
}
$table.find('thead').append('<tr>' + columns.join('') + '</tr>');
var rows = [];
for (var i = 0; i < json.length; i++) {
var row = json[i];
var tds = [];
for (var col in row) {
tds.push('<td>' + row + '</td>');
}
rows.push('<tr>' + tds.join() + '</tr>');
}
$table.find('tbody').append(rows.join(''));
}
}
 

Answers (7)