1
I can make an ajax for the service and return the data, I can display the first object Product and its properties, but when there is another object inside Productimage that has more than 5 objects inside, I cannot display their data
$.getJSON("http://www.dipes.com.br/web_api/products/9751/", function(data) {
console.log(data);
console.log(data.Product.name);
var output="<ul>";
for (var i in data.Product.ProductImage)
{
output+="<li>" + data.Product.ProductImage.i.http + "</li>";
}
output+="</ul>";
$('span').html(output);
});
This is André, I’ve done this before... and the error continued, the error is this: Html5.html:72 Uncaught Syntaxerror: Unexpected token [ In the console it shows that the error is in [. For you to be aware, I put the Dice in hand and still gives error. ex: console.log(data.Product.Productimage. 1.http);
– Tiago Marques
console.log(data.Product.Productimage.1.http); will give error, has to be console.log(data.Product.Productimage[1].http); I tested here and gave no error.
– André Vicente
This is the code I’m using: $. getJSON("http://www.dipes.com.br/web_api/products/9751/", Function(date) { console.log(data); console.log(data.Product.name); console.log(data.Product.Productimage.[1].http); var output="<ul>"; for (var i in data.Product.Productimage) { output+="<li>" + data.Product.Productimage. [i]. http + "</li>"; } output+="</ul>"; $('span'). html(output); }); Error: Unexpected token [
– Tiago Marques
You put "." too much. vc put "console.log(data.Product.Productimage.[1].http);" the correct is "console.log(data.Product.Productimage[1].http);" . After Productimage has no point
– André Vicente
Exactly!!! Stupid mistake, I’m sorry! Thanks for your help!
– Tiago Marques