0

I want to get the result of the .getJSON function to be accessible from outside the function. Here is my code:

var saveResult;
    $.getJSON($query, function(result){
        console.log("Result " +result);
        saveResult = result
        console.log(saveResult)
    });

telemetry = saveResult;
console.log(telemetry);

Inside the function, the variable saveResult is printed at the right way in the console. But outside the function, it is printed as undefined.

How can I get the right data outside of the function aswell?

Thanks in advance!

disprog
  • 72
  • 4

0 Answers0