1
My goal is that the Count variable gets the value that will accumulate in the arrayVec1 function, but instead I always get the result 0. Can someone tell me how I can pass the value out of the function and assign to the global variable?
Code:
//cout if exits
var count=0;
var vec = new Array();
var vec1= new Array();
var tag1="wedding ball evening gown";
arrayVec();
function arrayVec() {
$.getJSON("http://www.flickr.com/services/feeds/photos_public.gne?tags=soccer&format=json&jsoncallback=?",
function (jd) {
for (var i = 0; i < jd.items.length; i++) {
vec.push(jd.items[i]);
}
arrayVec1();
});
}
function arrayVec1() {
for (var i = 0; i < vec.length; i++) {
$.getJSON('http://www.flickr.com/services/feeds/photos_public.gne?tags='+"ball"+'&format=json&jsoncallback=?',
function (jd) {
for (var i = 0; i < jd.items.length; i++) {
if (tag1 === jd.items[i].tags) {
count++;
}
}
});
}
}
alert(count);
Possible duplicate: http://answall.com/q/60852/129
– Sergio
Possible duplicate also: http://answall.com/q/58566/129
– Sergio