So I am looking for a little bit of guidance, tips and knowledge transfer. Currently I am practicing fetching JSON data, but I am having some issues.
My current problem I a running into is that my 3 variable (brand, desc and price) give me this error: Uncaught TypeError: Cannot read property 'Brand' of undefined
Can someone help me with this, also tips on better coding would be nice.
var url = 'https://raw.githack.com/gromstone/jsonFiles/master/products.json';
$.ajax({
type: 'GET',
dataType: 'json',
url: url,
success: function(data){
console.log(data);
$.each(data, function(i, products){
var content = "<div class=\"item grid_4\">";
$.each(products, function(i, mainProd){
var brand = mainProd.ProductInfo.Brand,
desc = mainProd.ProductInfo.p_product_description,
price = mainProd.ProductInfo.p_product_price;
//content += '<img class="scale-with-grid" src="' + src + '"/>';
content += '<p>' + brand + desc + '</p>';
content += '<p>' + price + '</p>';
content += '<a>View More</a>';
});
content += "</div><!-- product -->";
$('.load').append(parent);
})
},
error: function(){
alert('Data did not load, or no connection')
}
});
You can see working code here: http://jsfiddle.net/gromstone/j1etxuw0/1/
Also if anyone can provide additional help, I want to make a hover effect for each one of the 'div.items' where some additional data is shown on a separate div (ex 'div.placeHolder')
Thanks!