score:4

Accepted answer

From HighCharts:

It is not possible to use the jQuery .getJSON() function on JSON files outside of your own domain. It is however possible to use JSONP.

You need to add a callback to your PHP, which wraps the JSON and then you return that JSON object:

Example:

<?php
header("content-type: application/json"); 

$array = array(7,4,2,8,4,1,9,3,2,16,7,12);

echo $_GET['callback']. '('. json_encode($array) . ')';    

?>

With those changes you can use use jQuery's $.getJSON() like so:

var url =  "http://url-to-your-remote-server/jsonp.php?callback=?";

$.getJSON(url,  function(data) {
    var yourJSONP = data;
    // render you chart here
});

Here are the relevant docs for Cross Domain Data:

http://www.highcharts.com/docs/working-with-data/getting-data-across-domains-jsonp


Related Query

More Query from same tag