我的代码运行为,
$.ajax({
url: "api/WepAPI/",
dataType: 'json',
success: function (result) {
alert(result.length);
$.each(result, function (index, element) {
alert(element.StartDate);
});
},
});
在迭代时,它会正确显示第一个元素的开始日期,对于所有其他元素,它会在警报中返回未定义的消息。
我的 WEBAPI 控制器代码看起来像,
public IEnumerable<Employees> GetAllEmployess()
{
EmpDataContainer context = new EmpDataContainer();
return context.Employees.AsEnumerable();
}
帮我解决这个错误...