first function gets json from a url and pushes it into array
var resultsArr = new Array();
// getResults()
// JSON response function -> takes uuid returned from search query
// and pings reponse url for any/all JSON objects of returned data
function getResults(req_uuid) {
console.log("url fetched");
$.getJSON( $SCRIPT_ROOT + "/respond?id=" + req_uuid, function(data) {
console.log(data);
resultsArr.push(data);
});
}
I have another function that runs on a click of a button that will pass uuid
into getResults()
at a given interval. This is all working. I'm even converting the entire array to a string and appending it into a div just before the call to the function in question. (this is also working). I'm logging the number of elements in the array before the call;
console.log( resultsArr.length + " items in array")
this logs = 4 items in array
then the function is called;
function showResults(array) {
var index = array.length;
console.log( index + " items in array");
}
this returns undefined items in array
. I am severely baffled.