$(document).ready(function(){
var currArray=null;
var group=null;
var admin=null;
var equipment=null;
var student=null;
console.log("after get array info");
for(var i=0; i<equipment.length; i++)
{
console.log("equipment at index after get array info: "+i+" val: "+equipment[i]);
}
setArray();
console.log("finished initial");
function getArrayInformation()
{
console.log("Get array information");
//equipment=new Array("Item ID", "Model", "Series", "Manufacturer");
$.post("Search", function(response)
{
console.log("back from Search AJAX");
$.each(response, function(index, val)
{
console.log("index of .each for Search AJAX response: "+index+" value of this: "+val);
jsonParse(index, val);
});
});
}
function jsonParse(index, val)
{
if(index == "equipment")
{
console.log("setting equipment array");
equipment = val.split(",");
console.log("equipment array after creating it");
for(var i=0; i<equipment.length; i++)
{
console.log("equipment at index: "+i+" val: "+equipment[i]);
}
}
else if(index == "student")
{
student = val.split(",");
}
else if(index == "group")
{
group = val.split(",");
}
else if(index == "admin")
{
admin = val.split(",");
}
}
As you can see I have the variable equipment equal to null initially. It is then set in jsonParse. However when I try to print out the values in it after the getArrayInformation function is finished the javascript console in Firefox says that it is null.
I am confused why it is saying that. The only thing I can think of is that it is only being set for local use in the jsonParse function. If in fact is only like that locally, however should I set it for global(within document.ready) use?