mvc ajax获取datatable,c# - How to load the datatable td values using ajax success function in mvc? - S...

在ASP.NET MVC应用中,作者遇到一个问题:尝试根据下拉框选择的年份在Ajax成功回调中动态加载DataTable的TD值,但未能成功。代码包括视图(View)、JavaScript脚本和控制器(Controller)的部分,主要涉及Ajax调用和DropDownList事件监听。作者请求帮助解决在年份变更事件中更新表格内容的问题。
摘要由CSDN通过智能技术生成

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

C01C02C03C04

@if (Model != null)

{

foreach (var item in Model)

{

@item.C01

@item.C02

@item.C03

@item.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.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值