So I'm trying to append data from the Url to the head of the table. The data called from the URL is a string list. So as you can see I'm trying to go through each value in the list and then append it to the head of my table, 'data'. But when I run the code nothing is appended. I know the data is going in because the window alert is displaying each of the strings.
JQuery:
$(document).ready(function () {
$.ajax({
url: 'http://..../api/Dynamic?table=table1',
dataType: 'Json',
success: function (tableResults) {
var count = 0;
$.each(tableResults, function () {
window.alert(this);
$('#data th:last-child').append('<th><a id="count">' + this + '</a></th>');
count++;
});
}
});
});
HTML:
<table id="data" border="1" align="center" width="95%">
<thead>
<tr>
</tr>
</thead>
<tbody>
</tbody>
</table>
Any suggestions?