Hi guys!
I'd like to store my json response in a global variable so, i could use it through my app without making a getJSON request more than once.
var data;
$.getJSON("panorama.json",function(json){
data = json.images[0].src;
console.log(data);   
});
console.log(data);
If I log it in the actual request its fine, but i get "undefined" everywhere else. Any comment appriciated.
Edit [copied from comments]: Tried ...
$.myglobals = { result: "unset" } 
$(document).ready(function() { 
  $.getJSON( "panorama.json", function(json) { 
    $.myglobals.result = json.images[0].src; 
    console.log($.myglobals.result);     
  });
  console.log($.myglobals.result); 
}) ;
The first log is okay, the second is undefined.
Edit [copied from answer]:
actually both method worked
the interesting thing is that my request was in a function and i tried to acces my global variable right after the request in the same function
when i accesed it outside the function it worked like a charm