You can create an action method that returns the HTML markup needed to display your table. Let me create a view model with which we will pass the table data.
public class ItemVm
{
public string ItemId {set;get;}
public string Line {set;get;}
public string Supplier {set;get;}
}
, . / . . .
public ActionResult TableData()
{
var items = new List<ItemVm>{
new ItemVm { ItemId="A1", Line="L1", Supplier="S1" },
new ItemVm { ItemId="A2", Line="L2", Supplier="S2" }
};
return PartialView("TableData",items);
}
,
@model List<ItemVm>
<table>
@foreach(var item in Model)
{
<tr><td>@item.ItemId</td><td>@item.Line</td></td>@item.Supplier</td></tr>
}
</table>
, , DOM . success ajax, . jQuery load DOM.
$(document).ready(function () {
$("#btnSave").click(function () {
$.ajax(
{
type: "POST",
url: "AdminInsert",
data: {
Line: $("#txtLine").val(),
Supplier: $("#txtSupplier").val()
}
}).success(function() {
$("#theTable").load("/YourControllerName/TableData");
});
});
. ItemVm, ViewBag.