Hello, I have the following code:
var marcas = {
nome: '',
fipeId: ''
};
var marcasVet = [];
var select;
$.ajax({
dataType: "json",
url: 'http://fipeapi.wipsites.com.br/carros/marcas',
success: function(data) {
for (var i = 0; i < data.length; i++) {
marcas.nome = data[i].name;
marcas.fipeId = data[i].id;
marcasVet[i] = marcas;
select += '<p> Marca: ' + marcasVet[i].nome + ' Marca id (Fipe): ' + marcasVet[i].fipeId + '</p>';
}
$('#info').html(select);
}
});
The data is stored in the marcasVet[]
vector and shown inside a div with id="info"
The problem is that when asking to show the information of marcas.fipeId
it only shows the value 120
, at any position of the marcasVet[]
vector.
Changing the code $('#info').html(select);
to $('#info').html(marcasVet[10].fipeId);
or any other position (1,2,3,4 ... 87) it shows only the value 120
.
I would like you to show the value it shows when you change to% var from%.
Does anyone know where the error is?
Thank you