I am having an issue with this variable not wanting to work outside the function and I just can't understand why! here's the code:
globalData = new Array();
//
// Colors
//
if ( settings.category == 'colors' ) {
$.getJSON(colorLoversURL, function(data) {
for ( var i in data ) {
var localData = data[i].hex;
globalData.push(localData);
}
});
}
//
// Palettes
//
else if ( settings.category == 'palettes' ) {
$.getJSON(colorLoversURL, function(data) {
for ( var i in data ) {
var localData = new Array();
for ( var j in data[i].colors ) {
localData.push(data[i].colors[j]);
}
globalData.push(localData);
}
});
}
Now the thing is that globalData is only keeping the values inside the getJSON function and out of the function, when I need it, It just comes up blank (I test the values in an alert window). I also tried taking the 'var' on and off the front of the code. Is there something wrong here?