I need to pass a parameter for make a query in Ajax file (query.php) for render json data for my flot chart.
I have a table when I click a row I take an ID necessary for the query
$("#dt-tabella tbody").on('click', 'tr', function () {
var data = table.row( this ).data();
$('#titoloGraf').text("Grafici : " + data[0]);
$.ajax({
url: "include/ajax/query.php",
type: "POST",
dataType: "json",
success: onDataReceived
});
});
...
function onDataReceived(series) {
data = [ series ];
$.plot("#Grafico", data, options);
}
<div class="flot-chart">
<div class="flot-chart-content" id="Grafico"></div>
</div>
On my query.php I need to take my parameter for the query (data[0]):
$tmp = filter_input(INPUT_GET, 'ID_param');
..somequery..
and my test result is something like
echo '{
"label": "'.$tmp.' (EU27)",
"data": [[1999, 3.0], [2000, 3.9], [2001, 2.0], [2002, 1.2], [2003, 1.3],
[2004, 2.5], [2005, 2.0], [2006, 3.1], [2007, 2.9], [2008, 0.9]]}';
Obviously at the end my var $tmp is not plot cause I don't know how to pass ID_param.
Any Idea is appreciated