-2

我需要在这段代码中输入 json :

$(function() {
    $.getJSON('http://www.highcharts.com/samples/data/jsonp.php?filename=aapl-c.json&callback=?', function(data) {
        // Create the chart
        $('#container4').highcharts('StockChart', {
            chart: {
            },

            rangeSelector: {
                selected: 1
            },

            title: {
                text: 'AAPL Stock Price'
            },

            series: [{
                name: 'AAPL Stock Price',
                data: data,
                type: 'spline',
                tooltip: {
                    valueDecimals: 2
                }
            }]
        });
    });
});

我的问题是当更改脚本上面的输入 json 时不起作用!!!!!!我的 json 字符串是:

?([[1159747200000,74.86],[1159833600000,74.08]]);

根据 highstock json 字符串

4

1 回答 1

0

json 生成更改为 EX:

json_encode("[[1159747200000,74.86],[1159833600000,74.08]]");

输入json(数据)更改为:

$(function() {

        $.ajax({ 
            url: 'http://localhost/server/json.php', 
            dataType: "json",
            success: function (data) { 

                var data_arr = $.parseJSON( data );

               $('#container4').highcharts('StockChart', {
            chart: {
            },

            rangeSelector: {
                selected: 1
            },

            title: {
                text: 'AAPL Stock Price'
            },

            series: [{
                name: 'AAPL Stock Price',
                data: data_arr,
                type: 'spline',
                tooltip: {
                    valueDecimals: 2
                }
            }]
        }); 

            }
        });
});
于 2013-09-30T14:59:23.990 回答