I have the following code to pass parameters to a function:
function updateBar(id, type, title, idDash, urls){
for(var i in urls){
var url = urls[i].url+'/'+id;
$.getJSON(url, function(data){
var dataHarvest = data['return'];
if(type === "Bar"){
barChart(dataHarvest, title, type, idDash, urls[i].id, urls);
}
});
}
}
urls
is an object that brings me query links and their id (These links are brought from a database).
When doing the route with the for
, it works well because it queries me every url
that I am sending and gets the data
of each query that is being made.
The problem is that I want the function barChart()
to send each of the ids
of the object urls
but only send me the last one, the other options are fine.
What I realize is that despite being the request GET
within a for, does not take into account the route. that is:
When doing a console.log(urls[i].id);
you should bring me 1 2 3
which are the ids, but it only brings me 3
I would like to know if there is a way to get all the ids when doing the path of the for or if there is a different way of doing this function that I am planning.