score:2

Accepted answer

the problem is that you create chart before ajax's response is received.

create chart inside callback, see:

$.getjson(
    'http://hostname/resturl/data',
    function (data) {
      var result = new array();

      for (i = 0; i < data.content.length; i++) {
          var alpha = new array();
          alpha.push(data.content[i].x);
          alpha.push(data.content[i].y);
          result.push(alpha);
      }

      chartobj.series[0].data = result;

      $('#pie-chart2').highcharts(chartobj);
  }
);

also, use chartobj for creating chart, not returned value from getjson() method.

score:0

specify the callback function for your ajax request .

$.getjson('http://www.highcharts.com/samples/data/jsonp.php?filename=analytics.csv&callback=?', function (csv) {

}

within your url append "callback=?" see the example


Related Query

More Query from same tag