如何在.NET MVC中使用jQuery并返回JSON数据
2个回答
2017-05-15 · 百度知道合伙人官方认证企业
育知同创教育
1【专注:Python+人工智能|Java大数据|HTML5培训】 2【免费提供名师直播课堂、公开课及视频教程】 3【地址:北京市昌平区三旗百汇物美大卖场2层,微信公众号:yuzhitc】
向TA提问
关注
展开全部
后台代码:
public JsonResult GetAnYou()
{
var aySql = "select * from T_User";
var ayResult = dbContext.Database.SqlQuery<AY>(aySql).ToList();
var data = ayResult.Select(p =>喊伍 new { MC = p.MC, DM = p.DM, FDM = p.FDM });
return Json(new { data = data }, JsonRequestBehavior.AllowGet);
}
JS代行尺码:
$.ajax({
url: "@Url.Content("~/Document/GetAnYou")",
data: { "ajlb": ajlxVal },
cache: false,
async: false,
success: function (result) {
$.each(result.data, function (index, firstValue) {
if (firstValue.FDM == 0) {
mydtree.add(firstValue.DM, 0, firstValue.MC, '', firstValue.MC, "档渗高_self", false);
$.each(result.data, function (index, secondValue) {
if (secondValue.FDM == firstValue.DM) {
mydtree.add(secondValue.DM, firstValue.DM, secondValue.MC, '', secondValue.MC, "_self", false);
$.each(result.data, function (index, thirdValue) {
if (thirdValue.FDM == secondValue.DM) {
mydtree.add(thirdValue.DM, secondValue.DM, thirdValue.MC, "javascript:setvalue('" + thirdValue.DM + "','" + thirdValue.MC + "')", thirdValue.MC, "_self", false);
}
});
}
});
}
});
document.write(mydtree);
}
});
public JsonResult GetAnYou()
{
var aySql = "select * from T_User";
var ayResult = dbContext.Database.SqlQuery<AY>(aySql).ToList();
var data = ayResult.Select(p =>喊伍 new { MC = p.MC, DM = p.DM, FDM = p.FDM });
return Json(new { data = data }, JsonRequestBehavior.AllowGet);
}
JS代行尺码:
$.ajax({
url: "@Url.Content("~/Document/GetAnYou")",
data: { "ajlb": ajlxVal },
cache: false,
async: false,
success: function (result) {
$.each(result.data, function (index, firstValue) {
if (firstValue.FDM == 0) {
mydtree.add(firstValue.DM, 0, firstValue.MC, '', firstValue.MC, "档渗高_self", false);
$.each(result.data, function (index, secondValue) {
if (secondValue.FDM == firstValue.DM) {
mydtree.add(secondValue.DM, firstValue.DM, secondValue.MC, '', secondValue.MC, "_self", false);
$.each(result.data, function (index, thirdValue) {
if (thirdValue.FDM == secondValue.DM) {
mydtree.add(thirdValue.DM, secondValue.DM, thirdValue.MC, "javascript:setvalue('" + thirdValue.DM + "','" + thirdValue.MC + "')", thirdValue.MC, "_self", false);
}
});
}
});
}
});
document.write(mydtree);
}
});
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询