My goal is for the count variable to get the value that will accumulate in the arrayVec1 function, but instead I always get the result 0. Can anyone tell me how I can pass the value out of the function and assign it 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);