I am doing the following:
$.getJSON(url,function(data){
var totalQueries = data.length;
$.each(data, function(i, item) {
But this one looks like to be wrong:
var totalQueries = data.length;
As by the end of it I check for the last item and it never happens:
if (i === totalQueries - 1) {
myId = item.pageid;
console.log(myId);
newQuery();
}
datais an array and not an object?datais an array as I can read it, I get no errors as the code is correct, but I can see thatconsole.log(myId);doesn't happen which means the conditional isn't happening @AlexanderNiedtotal length of a function(data)makes no sense ... you're getting the length property of the returned parsed JSON. If the top level "object" is an Array, the length property is the number of elements in the arraydatawould help - perhaps the last item in the array is not an object with a pageid property