Hi i want to load the data table td values in ajax success function in mvc. I tried to load the datatable td values in ajax success function while changing the year . But its not working.Below i have attached my code.
My View
@model IEnumerable
@{
ViewBag.Title = "Summary";
Layout = "~/Views/Shared/_Layout.cshtml";
}
Details
@Html.DropDownList("OperationddlYear10", Model.First().lstYear, new { @class = "form-control top-filter" })
| C01 | C02 | C03 | C04 |
|---|
My Script
$('#OperationddlYear10').on('change', function () {
$(".DCDIYresult_year").text($('#OperationddlYear10 :selected').text());
var yr= $("#OperationddlYear10").val();
$.ajax({
type: "Post",
url: '@Url.Action("GetData", "Home")',
datatype: "Json",
data: { Year: yr, pval: 1 },
success: function (data) {
$('tbody').html(data);
}
});
});
My Controller
public JsonResult GetData(int Year=3, int pval=0)
{
try
{
BAL bal = new BAL();
List
model = bal.GetData(Year, pval);
return Json( model , JsonRequestBehavior.AllowGet);
}
catch (Exception ex)
{
Common.AddModel_Log4Net();
throw new Exception(ex.ToString());
}
}
Above is my code.Now i want to load the table values in ajax success function on year change
event but it is not working any one check and help me to resolve this issue .Thanks.

Jignesh KumarRank #91 · 22.9K reputationPosted Sep 20, 2020, 8:35 PM EDT