如何遍历jquery成功的对象之一?

问题描述:

我从控制器通过使用return Json(new {success = true , product, list});我只需要通过“产品”进行迭代,查看两个对象object.Is有可能在jQuery的?。我试过如何遍历jquery成功的对象之一?

$.each(response, function (index, el) {   
}); 

那么它也可以通过“清单”迭代也。以下是控制器在ajax成功中的响应。

[Object, Object]------->values of product 
0: Object 
    CategoryID: 0 
    Description: null 
    PhysicalPath: null 
    ProductCategory: null 
    ProductID: 41 
    Title: "Woo Album" 
    Tooltip: null 
    VirtualPath: "~/Content/images/pro-cat-6.jpg" 
1: Object 
    CategoryID: 0 
    Description: null 
    PhysicalPath: null 
    ProductCategory: null 
    ProductID: 42 
    Title: "EverShine Memories" 
    Tooltip: null 
    VirtualPath: "~/Content/images/pro1.jpg" 

[7, 8] ---->values of list 
+0

您需要提供什么样的'product'和'list'样子?此外,你得到的索引,所以你可以达到所需的元素仍然需要向我们展示一些数据 – Tushar

+0

你可以发布你的'响应'对象的样子? –

+0

[Object,Object] 0:ObjectCategoryID:0描述:nullPhysicalPath:nullProductCategory:nullProductID:41Title:“Woo Album”工具提示:nullVirtualPath:“〜/ Content/images/pro-cat-6.jpg”__ proto__:Object1:ObjectCategoryID:0Description :nullPhysicalPath:nullProductCategory:nullProductID:42Title:“EverShine Memories”工具提示:nullVirtualPath:“〜/ Content/images/pro1.jpg”__ proto__:Objectlength:2__proto__:Array [0] ProductDisplay:286 [7,8] – neethu

您想要的对象不是孩子的回答吗?你不应该只用response.product来代替吗?

$.each(response.product, function (index, el) {   
}); 

不是传递名单通过return Json(new {success = true , product, list});return Json(new {success = true , product, start=startIndex,end = endindex});和jQuery中使用的变量作为response.start到Response.End和