I have the following data in an array.
[{"FirstName":"Nancy","LastName":"Davolio","Title":"Sales Representative"},
{"FirstName":"Andrew","LastName":"Fuller","Title":"Vice President, Sales"}]
I want to present this data using jquery into a table like this :
<table id="employee">
<tr>
<td>Nancy</td>
<td>Davolio</td>
<td>Sales Representative</td>
...
</table>
similar
$(document).ready(function() {
var jsonp = '[{"Lang":"jQuery","ID":"1"},{"Lang":"C#","ID":"2"}]';
var lang = '';
var obj = $.parseJSON(jsonp);
$.each(obj, function() {
lang += this['Lang'] + "<br/>";
});
$('span').html(lang);
});
I did something like this before:
var apiUrl = 'UrlOfData';
$(document).ready(function () {
$.getJSON(apiUrl)
.done(function (data) {
for (var item in data){
$('#people').append(item.FirstName);
}
})
.fail(function (jqXHR, textStatus, err) {
$('#people').text('Error: ' + err);
});
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With