Вот рабочая демонстрация:
Просмотр (Index.cs html):
<table border="1">
<tr>
<th></th>
<th>Col 1</th>
<th>Col 2</th>
<th>Col 3</th>
<th>Col 4</th>
<th>Col 5</th>
</tr>
<tr>
<td>Row 1</td>
<td id="12" class="text-right bg-red"></td>
<td id="13" class="text-right bg-red"></td>
<td id="14" class="text-right bg-gray"></td>
<td id="15" class="text-right bg-red"></td>
<td id="16" class="text-right bg-gray"></td>
</tr>
</table>
<br />
<input type="text" id="text1" />
<br />
<input type="date" id="date1" />
<br />
<button onclick="Test()">Send</button>
@section Scripts
{
<script>
function Test() {
var text = $("#text1").val();
var date = $("#date1").val();
var list = [];
$("td.text-right.bg-red").each(function () {
var id = $(this).attr("id");
list.push(id);
}
);
console.log(list);
var data = {
text: text,
date: date,
list: list
};
console.log(data);
$.ajax({
type: "POST",
url: "/Home/Test",
data: data,
success: function () {
//do your stuff...
},
dataType: "application/json"
});
}
</script>
}
Контроллер:
public IActionResult Index()
{
return View();
}
[HttpPost]
public IActionResult Test(string text,DateTime date,List<string> list)
{
return Json(text);
}
Результат: