I'm using Ajax in my Asp.net core 2.2 which works just fine but I'm stack with the Json value which returns undefined
since in the View I'm using a different way to post the Data in the page.
(我在Asp.net core 2.2中使用了Ajax,它工作正常,但是我与Json值堆叠在一起,该值返回undefined
因为在View中,我使用了另一种方式将数据发布到页面中。)
How can ajax GET
the correct data when My View looks like:
(当“我的视图”如下所示时,ajax如何GET
正确的数据:)
<div class="treeview">
@{
if (Model._InstanceDepartment != null && Model._InstanceDepartment.Count() > 0)
{
<ul>
@foreach (var i in Model._InstanceDepartment)
{
<li>
<span class="collapse collapsible" data-loaded="false" pid="@i.DepartId"> </span>
<span>
<a href="#@i.NavUrl" onclick="mydevpartmanifested()">@i.DepatName</a>
</span>
</li>
}
</ul>
}
}
</div>
And Ajax Get the Data from Controller Like
(和Ajax一样从Controller获取数据)
$.ajax({
url: "/User/SubMenu",
type: "GET",
data: data,
dataType: "json",
success: function (d) {
$(this1).removeClass("loadingP");
if (d.length > 0) {
var $ul = $("<ul></ul>");
$.each(d, function (i, ele) {
$ul.append(
$("<li></li>").append(
"<span class='collapse collapsible' data-loaded='false' pid='" + ele.DepartId + "'> </span>" +
"<span><a href='" + ele.NavUrl + "'>" + ele.DepatName + "</a></span>"
)
)
});
$(this1).parent().append($ul);
$(this1).addClass('collapse');
$(this1).toggleClass('collapse expand');
$(this1).closest('li').children('ul').slideDown();
}
else{...} ../code continue just fine.
The problem is that I'm no getting the life of data from Model
But from Model.__InstanceDepartment
(问题是我没有从Model
而是从Model.__InstanceDepartment
获取数据寿命)
VS2019 DEBUG show like:
(VS2019 DEBUG展示像:)
What I need is that the data which is found under _InstanceDepartment
as shown on the picture, must be accessible in if(d.length > 0)
to display the data.
(我所需要的是,这是根据找到的数据_InstanceDepartment
上的画面如图所示,必须是在可访问的if(d.length > 0)
以显示数据。)
Currently, it's displays none, undefined
(当前,不显示任何内容( undefined
)
Anyone Has a Fast/Quick way to do this??
(有人有快速/快速的方法吗?)
ask by PatsonLeaner translate from so
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…