Посылаю запрос на сервер
$.ajax({
url: '/shop/cart/api/sync',
dataType: 'json',
success: function(response) {
alert(response.data.items.length);
}
});
в ответ приходит массив элементов:
{"success":true,"errors":false,"data":{"items":{"cartItem_81_92":{"id":81,"vId":92,"price":"172.00","addprice":"5.33","origprice":"172.00000","name":"Samsung DVD-H1080 - 1080p","vname":"","count":8,"maxcount":7,"number":"AD-78-SA-QW","url":"http:\/\/fast.ostrova-holding.ru\/shop\/product\/81","img":"http:\/\/fast.ostrova-holding.ru\/uploads\/shop\/products\/small\/81_vM92.jpg","prodstatus":{"action":true,"hot":true,"hit":true}},"cartItem_109_120":{"id":109,"vId":120,"price":"1591.94","addprice":"49.35","origprice":"1591.93542","name":"Panasonic KX-TG6445 Cordless Phone","vname":"","count":1,"maxcount":9,"number":"","url":"http:\/\/fast.ostrova-holding.ru\/shop\/product\/109","img":"http:\/\/fast.ostrova-holding.ru\/uploads\/shop\/products\/small\/109_vM120.jpg","prodstatus":[]},"cartItem_105_116":{"id":105,"vId":116,"price":"39.98","addprice":"1.24","origprice":"39.98000","name":" \u0411\u0443\u0442\u0435\u0440 \u0438\u0437 \u0410\u0414\u0410","vname":"30 \u0441\u043c","count":2,"maxcount":2,"number":"","url":"http:\/\/fast.ostrova-holding.ru\/shop\/product\/105","img":"http:\/\/fast.ostrova-holding.ru\/uploads\/shop\/products\/small\/e55459c85671aff6b5b60cc5a4b2e698.png","prodstatus":[]},"cartItem_105_224":{"id":105,"vId":224,"price":"10.00","addprice":"0.31","origprice":"10.00000","name":" \u0411\u0443\u0442\u0435\u0440 \u0438\u0437 \u0410\u0414\u0410","vname":"15 \u0441\u043c","count":1,"maxcount":1,"number":"","url":"http:\/\/fast.ostrova-holding.ru\/shop\/product\/105","img":"http:\/\/fast.ostrova-holding.ru\/uploads\/shop\/products\/..\/nophoto\/nophoto.jpg","prodstatus":[]}}}}
во-первых на alert(response.data.items.length); ругается, соответственно не могу сделать for по массиву.