JSON返回列表<客户> [英] json returning list<customers>

查看:109
本文介绍了JSON返回列表<客户>的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要回列表<客户> 的JSON结果在我的控制器。在客户端脚本,我可以看到客户的精细返回。

我可以以某种方式使用forin循环?因为当我尝试它说,VAR我是不确定的。

 为(VAR我在客户)
{
警报(i.CustomerName);
}


解决方案

尝试:

 为(VAR我在客户)
{
    警报(客户[I] .CustomerName);
}

i'm returning List<Customer> as json result in my controller. in the client script i can see the customers fine being returned.

can i somehow use the forin loop? because when i try it says that var i is undefined.

for (var i in customers)
{
alert(i.CustomerName);
}

解决方案

try:

for (var i in customers)
{
    alert(customers[i].CustomerName);
}

这篇关于JSON返回列表&LT;客户&GT;的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆