gabricocchi Posted June 10, 2013 Share Posted June 10, 2013 I'm having some problems with $.getJSON, I really need some help because I don't know how to solve the problem and I've been stuck here for days. This is the js file that should generate highcharts when selecting a select option in HTML: $(document).ready(function() { $("#paese").change(function(){ var seriesOptions = []; $.getJSON("prova.php", function(data) { seriesOptions = data; }); var chart1 = new Highcharts.Chart({ chart: { renderTo: 'container', type: 'column', spacingLeft: 20, borderWidth: 1 }, .... series: [{ name: 'Italia', data: seriesOptions }], Is there anything wrong in the first part? When I select an option, it seems like highcharts don't get the php file, but I'm pretty sure it's correct, here it is(PHP file): <?PHP header("Content-Type: application/json; charset=UTF-8"); $conn = mysql_connect("localhost", "root"); $paese = null; if(isset($_GET['paese'])) $paese = $_GET['paese']; $ok = mysql_select_db("liberta", $conn); $response = array(); $sql="SELECT `valori`.Punteggio FROM `valori` INNER JOIN `nazioni` ON `valori`.Nazione = `nazioni`.ID WHERE `nazioni`.Nome = '$paese'"; $res=mysql_query($sql); while($record=mysql_fetch_row($res)){ $response[] = intval("$record[0]"); } mysql_close($conn); print(json_encode($response)); ?> I'm trying to get the data from a database I created with PHPmyadmin and put them directly into highcharts, but it doesn't work. I'd be very pleased if you could help me, also because this is is an exam I have to sit. Thank you very much. Quote Link to comment https://forums.phpfreaks.com/topic/279006-putting-data-from-a-database-into-highcharts-with-getjson/ Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.