I have made a small (test) script that parses a JSON file (I use https://jsonplaceholder.typicode.com in the example below) and makes table rows out of the resulting object.
I am trying to append these rows to a table.
See the jsFiddle HERE.
I get an
Unexpected identifier
You were appended the data wrong way. Replace your this portion of code by this.
var root = 'https://jsonplaceholder.typicode.com';
var tableRow = '';
$.ajax({
url: root + '/users',
method: 'GET',
success: function(data) {
for (var i = 0; i < data.length; i++) {
var tableRow = '<tr><td>' + data[i].name + '</td><td>' + data[i].email + '</td><td>' + data[i].email + '</td></tr>';
$("#dataTable").find('tbody').append(tableRow);
}
},
error: function() {
var tableRow = '<tr><td>There is no data to display</td></tr>';
console.log(tableRow);
}
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<table class="table" id="dataTable">
<thead>
<tr>
<th>Full Name</th>
<th>Email</th>
<th>Address</th>
</tr>
</thead>
<tbody></tbody>
</table>