I am trying to store my response from d3 async call to a global variable. I have gone through the discussions why a variable is not updated with aysnc calls because of the time they take to return the responses. I have tried something like this
var x = []; // global variable
d3.json("url", function(response)
{
callback(response); //passing response to call back
});
function callback(data)
{
x = data; // assigning data to x ;
}
$(document).ready(function () {
console.log(x);
});
Still my x is undefined. can anybody help with this ! I have tried couple of solutions from other posts but nothing worked. How can i access my x[] in $(document).ready function(function()){}