Possible Duplicate:
JavaScript asynchronous return value / assignment with jQuery
I need a prototype of chart with constructor, so I wrote this:
function Chart(file) {
  var chart = undefined
  $.getJSON(file, function(data) {
    chart = {
      categories: data.keys
      series: [{
          name: 'first',
          data: data.first
        }, {
          name: 'second',
          data: data.second
      }]
    }
  });
  return chart
}
Then I realized, that because of JaavScript's synchronousness it returns undefined. How should I defere the return statement of Chart? 
 
     
    