I'm just a beginner and I want to show data from my database (MySQL) and display it in a line chart using JQPLOT. I have a PHP file that takes the data from the database and converts it into a JSON array which, as I understand, is what JQPLOT needs to display it properly. The problem I'm having is that I've never used AJAX before.
The JQPLOT website gives me this code:
$(document).ready(function(){
var ajaxDataRenderer = function(url, plot, options) {
var ret = null;
$.ajax({
async: false,
url: url,
dataType:"json",
success: function(data) {
ret = data;
}
});
return ret;
};
// The url for our json data
var jsonurl = "./jsondata.txt";
var plot2 = $.jqplot('chart2', jsonurl,{
title: "AJAX JSON Data Renderer",
dataRenderer: ajaxDataRenderer,
dataRendererOptions: {
unusedOptionalUrl: jsonurl
}
});
});
I don't understand the second half of this code, but I want to know how I can incorporate my PHP file (that contains the json array) into this code and display a line chart. Or maybe if anyone has a simpler code where I can implement the PHP file and still able to show the line chart? Im just very new at this, please help.