json - How to read data from in Javascript -


i'm trying use javascript read stock data yahoo finance @ "http://table.finance.yahoo.com/table.csv?s=000001.sz", returns csv file , convert data json format in http://www.highcharts.com/samples/data/jsonp.php?filename=aapl-ohlcv.json&callback=? used in highcharts.

i tried using $.ajax , jquery.get neither worked. can tell me how read data url , convert json? lot.

this can done php.

<?php file_put_contents("data.csv", fopen("http://table.finance.yahoo.com/table.csv?s=000001.sz", 'r'));  //reads csv file , save value associative array function csv_to_array($filename = '', $delimiter = ',') {     if (!file_exists($filename) || !is_readable($filename))         return false;      $header = null;     $data   = array();     if (($handle = fopen($filename, 'r')) !== false) {         while (($row = fgetcsv($handle, 1000, $delimiter)) !== false) {             if (!$header)                 $header = $row;             else                 $data[] = array_combine($header, $row);         }         fclose($handle);     }     return $data; }  $arr = csv_to_array('data.csv');  //<pre></pre> tags appear prevent white-space collapsing  //prints associative array echo "<pre>"; print_r($arr); echo "</pre>";  //displays the json echo "<pre>"; echo json_encode($arr, json_pretty_print); echo "</pre>"; ?> 

now depending on format of json acceptable highcharts api, required tweak how array encoded json. avoid using json_pretty_print if size of incoming data large.