tags:

views:

56

answers:

2

Sorry for the noob question. I've read through a couple questions and am unable to solve my problem. I cannot seem to load the data.

I have the following json code output from a php script.

{label: "load",data:[[1283294013*1000, 2.03],[1283293998*1000, 2.04],[1283293983*1000, 2.06],[1283293968*1000, 1.99],[1283293953*1000, 1.98],[1283293937*1000, 1.98],[1283293922*1000, 1.97],[1283293907*1000, 1.97],[1283293892*1000, 1.96],[1283293877*1000, 1.95],[1283293862*1000, 2.03]]}

With the following options

  var options = {
    legend: {
      show: true,
      margin: 10,
      backgroundOpacity: 0.5
    },
    lines: { show: true },
    xaxis: {
      mode: "time",
      timeformat: "%H:%M"
    },
    yaxis: { min: 0, },
    grid: { hoverable: true }
  };

The actual script looks like the following

  var plotArea = $("#plotArea");
  plotArea.css("height", "450px");
  plotArea.css("width", "800px");

  $.getJSON("getStats.php", function(data) {
      alert(data);
      $.plot( plotArea , data, options );
    });

The alert doesn't load at all. With FireBug, I can see the data was returned but nothing happens.

When using the following instead, data passes. The alert runs and a graph shows up with nothing on the graph.

$.get("getStats.php", function(data) {
      alert(data);
      $.plot( plotArea , data, options );
    });

I can get this to run when just including the getStats.php in the code but that's not really what I'm shooting for.

+1  A: 

JSON data mustn't contain math operations (multiplications in your case). Send already calculated values instead of expressions.

Vadim Shender
I tried modifying the results to already have computed the time. The output looks like the following {label: "load",data:[[1283298376000, 1.01],[1283298361000, 1.01],[1283298346000, 1.02],[1283312642600000, 1.08],[1283312627600000, 1.10]]}The getJSON portion is still not functioning even though the above was being returned. The results return but the alert, for instance, is not run.
ScrewzLuse
A: 

also I would expect the last 3 characters to look like ]]} not ]},

Hogan
Oops, sorry about that. I actually just copied it wrong. There is ]]}. I fixed the question. Thanks. :-)
ScrewzLuse