I have an ajax request polling my server every 5 seconds which returns a json array of data that is available for an users shopping carts contents.
The json is correctly formed and is being returned everytime without problem.
JSON
[
{
"status": "success",
"responsecode": "00",
"data": [
{
"partnumber": "Part 1",
"status": "true",
"quantity": "4",
"productid": "item-1",
"name": "Product 2",
"online": "1"
},
{
"partnumber": "Part 2",
"status": "false",
"quantity": "0",
"productid": "item-2",
"name": "Product 2",
"online": "1"
}
]
}
]
Jquery function to process the ajax response
function doPoll(){
$.ajax({
type: "get",
url: "/assets/static-pages/shopping-cart/?action=check-cart",
dataType : 'json',
success: function(html) {
$.each(html, function(key, value)
{
console.log(value.data[key].partnumber);
}
);
}
});
// setTimeout(doPoll,10000);
}
every time it loops, all it does is return the first item in the array, I would very much like to loop the array and return all that resides within the "data" array so I can manipulate the UI based on its contents, but for some reason I cant figure out how to get all the data.
any suggestions greatly appreciated