i'm trying to pull data from a mysql database and plot in a flot chart. i've seen dozens of posts but it's not working for me. I successfully get flot charts working in php http://oven.luckybat.space/batoven1.0_s.php
firstly here's the url for the data intellipool.overcast.net.au/PCsystem/getdataforflot.php it seems to be in the correct format. i want to plot temperature versus time
I get an 'error alert' when i load the page that runs this script
there is a
<p> id="graph3" style="width:1000px;height:500px;">graph3</p>
on the wordpress webpage
help appreciated
$.ajax({
type: "GET",
dataType: 'json',
url: 'http://intellipool.overcast.net.au/PCsystem/getdataforflot.php',
error: function() {
alert("An error occurred.");
},
success: function(data) {
alert("got the data dude");
var options = {
xaxis: {
mode: "time",
mintickSize: [1, "hours"],
axisLabel: 'Time',
min: ((new Date().getTime()) - 24 * 60 * 60 * 1000),
max: (new Date()).getTime()
},
yaxes: [{
tickFormatter: function(val, axis) {
return val + "\u00B0C";
},
max: 50,
axisLabel: "Temperature",
axisLabelUseCanvas: true,
axisLabelFontSizePixels: 12,
axisLabelPadding: 5
}, {
position: "right",
tickFormatter: function(val, axis) {
return val + "%";
},
max: 100,
axisLabel: "Humidity",
axisLabelUseCanvas: true,
axisLabelFontSizePixels: 12,
axisLabelPadding: 10
}],
};
$.plot("#graph3", data, options);
}
});
as per instructions i've added
<header> ('Access-Control-Allow-Origin: *'); </header>
to http://intellipool.overcast.net.au/PCsystem/getdataforflot.php
i'm still getting the error, do i need to do more on the server (by contacting hosting?)
do i need to assign JSON data coming in to a variable?
the full function() is
function ajaxplot() {
document.write('hello!! there ajaxplot() AJAX has been called');
$.ajaxSetup({ cache: false });
$.ajax({
type: "GET",
dataType: 'json',
url: 'http://intellipool.overcast.net.au/PCsystem/getdataforflot.php',
error: function() {
alert("An error occurred.");
},
success: function(data) {
alert("got the data dude");
var options = {
xaxis: {
mode: "time",
mintickSize: [1, "hours"],
axisLabel: 'Time',
min: ((new Date().getTime()) - 24 * 60 * 60 * 1000),
max: (new Date()).getTime()
},
yaxes: [{
tickFormatter: function(val, axis) {
return val + "\u00B0C";
},
max: 50,
axisLabel: "Temperature",
axisLabelUseCanvas: true,
axisLabelFontSizePixels: 12,
axisLabelPadding: 5
}, {
position: "right",
tickFormatter: function(val, axis) {
return val + "%";
},
max: 100,
axisLabel: "Humidity",
axisLabelUseCanvas: true,
axisLabelFontSizePixels: 12,
axisLabelPadding: 10
}],
};
$.plot("#graph3", data, options);
}
});
}