Using jQuery to build table rows from Ajax response(Json)
Using jQuery to build table rows from Ajax response(Json)
HTML
<table id="records_table" border='1'>
<tr>
<th>IP</th>
<th>Org</th>
<th>Region</th>
</tr>
</table>
JavaScript
var jsonData = 'https://gist.githubusercontent.com/complicatedbull/c148553074e30f41fe30ea1f4ed26bbf/raw/b0261d567c99be83311a928ffb74521da655a277/ipinfo.json'
$.ajax({
url: '/echo/json/',
type: 'GET',
data: {
json: jsonData
},
success: function (response) {
var trHTML = '';
$.each(response, function (i, item) {
trHTML += '<tr><td>' + item.ip + '</td><td>' + item.org + '</td><td>' + item.region + '</td></tr>';
});
$('#records_table').append(trHTML);
}
});