I have two files. One is a php with mysql connection. If I open manually with my browser I see the right values. For example: [["4","5.000"],["5","1.000"]]
The code:
$query = "SELECT id, wert FROM stat_cpu ORDER BY id LIMIT 100";
$result = mysql_query($query,$db);
while($row = mysql_fetch_assoc($result))
{
$dataset1[] = array($row['id'],$row['wert']);
}
echo json_encode($dataset1);
I want to show the data in a plot. If I put the values manually in the js all work good. But how can I put it automaticall from the php to the js file?
I have tried this:
...
$.ajax({
url: 'cpudaten.php',
dataType: 'json',
success: function(data)
{
var cpudaten = data[0];
}});
var updateInterval = 30;
var plot_statistics = $.plot($("#load_statistics"),
[cpudaten], {....