У меня есть список, который возвращается из функции $ .ajax. Я хотел бы добавить возвращенный список в таблицу. Ниже приведен фрагмент кода, с которым я работаю.
$(document).ready(function() {
$.ajax({
type: "POST",
url: "Home/LoadTable",
success: function(data) {
var loopList = data.message.NewList;
alert(loopList);
//tried the following :(
//loopList.each(function(i) {
// addRecentData(i);
//});
},
error: function() {
alert("ERROR");
}
});
});
function addRecentData(data) {
$('#newTable tr:last').after('<tr><td class="date"></td><td class="name"></td></tr>');
var $tr = $('#newTable tr:last');
$tr.find('.date').html(data.message);
$tr.find('.name').html(data.message.NewList[0].Name.toString());
}
Таблица
<table id = "newTable">
<tr>
<td class="date"></td>
<td class="polNum"></td>
</tr>
</table>