Hello once again SO users :)
I have made a json string which should work with the chart (actually it works, but only when I do a hardcoded copy-paste instead of runtime work), but sadly the series won't render.
I was trying few things:
- checking the variable scopes
- paste the JSON data as it would be hardcoded (it works then, but it's not the solution)
- checking if the JSON string is valid (JSON.parse() gives true)
doing some sleep-style functions (it didn't help)
This is my JS code (I would use jsfiddle, but there is a $.get from DB so I can't do it :(
<script type="text/javascript"> $("#clickMe").click(function(event){ $.get( '../action/jsonHChart.php', { productName: 'Snickers' }, function (jsonData) { $("#jsonBug").val(jsonData); } ); $("#hc_container").highcharts({ chart: { renderTo: 'hc_container' }, series: [{ name: 'Price', data: $("#jsonBug").val() // using variable won't help either }] }); }); </script>
Edit: Transforming the code to use highcharts in $.get callback didn't help.
Yet another not working version (just FYI)
<script type="text/javascript">
$("#clickMe").click(function(event){
$.get( '../action/jsonHChart.php',
{ productName: 'Snickers' },
function (jsonData) { $("#hc_container").highcharts({
chart: {
renderTo: 'hc_container'
},
series: [{
name: 'Price',
data: jsonData
}]
}); }
);
});
</script>
Here is the link to demo of the problem, the code is quite clean (some bootstrap meta and head tags are left)
http://nowshop.pl/libs/page/a.php
You can view the full code with firebug