我使用.NET MVC4内部对象如何获得价值通过Json的
我用javascript函数如下:
function ShowDomainComponentDetail(compCode) {
alert(compCode);
$.ajax({
url: "/PP/getDomainComponentDetailWithDomain",
data: {
'ComponentCode': compCode
},
dataType: "json",
type: 'POST',
cache: false,
success: function (_responseData) {
$('#divShowDomainCompDetail').show();
alert(_responseData.Data)
},
error: function() {
//
}
});
}
成功后我得到的名单。NET为:
IdObservation=1, ObservationName="Started" , ObsType="Announced";
IdObservation=2, ObservationName="Not Started" , ObsType="Un Announced";
IdObservation=3, ObservationName="Declared" , ObsType="Announced";
我的问题是我不是abl; e访问Ajax成功块内的这个列表。
我如何可以访问此列表为:
alert(_responseData.IdObservation);
alert(_responseData.ObservationName);
(而且我要去这个分配到标签)。
请帮帮我。
编辑1:
我Serverside集团函数返回列表:
public JsonResult getDomainComponentDetailWithDomain(string ComponentCode)
{
try
{
List<TEAMS_PP.Entity.correlations> compDetail_list = new correlation().getDomainComponentDetailswithDomain(ComponentCode);
return Json(compDetail_list);
}
catch (Exception)
{
List<TEAMS_PP.Entity.correlations> BlankList = new List<TEAMS_PP.Entity.correlations>();
return Json(BlankList);
}
}
你是如何从服务器返回列表? – James
@James PLZ看EDIT1 –
酷只是确保你正确地发回它,你的结果很简单的对象数组(你可以看到,如果你使用调试器)。请参阅下面的@ Bhushan的答案。 – James