0

I have a very classic Linechart, getting data from php script in JSON format. However, I want to update that graph at regular interval.

var jsonData1 = $.ajax({ url:"./scripts/json_papp.php", dataType:"json", async:false }).responseText;
var data1 = new google.visualization.DataTable(jsonData1);
var chart1 = new google.visualization.LineChart(document.getElementById('papp_div'));
chart1.draw(data1, opt1);
setInterval("updatePAPP()", 6000);

function updatePAPP() {
// here I need to get again the data from the script and draw it again.
}
4

1 回答 1

0

你可以这样尝试:

function updatePAPP() {
    $.ajax({ url:"./scripts/json_papp.php", dataType:"json", async:false }).done(function(jsonData1) {
        var data1 = new google.visualization.DataTable(jsonData1);
        var chart1 = new google.visualization.LineChart(document.getElementById('papp_div'));
        chart1.draw(data1, opt1);
    }
}
于 2013-10-07T22:15:49.803 回答