score:0
You need to read up on Ajax, and also on jQuery.
Try this first
function chooseCategory(mat_id){
$.post("test.php",{"id":mat_id},function(data) {
window.console && console.log(data);
});
}
then when you are happy try the highcharts which has to be loaded of course
function chooseCategory(mat_id){
$.post("test.php",{"id":mat_id},function(data) {
$('#container3').highcharts({
series: [{ "type":"line", "name": "#numbers", "data": data }]
});
});
}
score:1
Since the Ajax call is asynchronous, you need to wait for it to complete before loading Highcharts. To do this you typically use a callback. Put the chart-loading code into a function "loadCharts(data)", and invoke that from inside the Ajax handler. Something like this:
function chooseCategory(mat_id){
// ...
ajax.onreadystatechange = function() {
if(ajaxReturn(ajax) == true) {
data_ajax = ajax.responseText;
alert(data_ajax);
loadCharts(data_ajax);
}
};
}
function loadCharts(data_ajax)
$('#container3').highcharts({ ... });
}
score:1
Just define a function which calles highcharts.
var drawChart = function(data_ajax) {
$('#container3').highcharts({
...
...
series: [{ type: 'line', name: '#numbers:', data: data_ajax
});
}
And then instead of alert the data simply call the function:
drawChart(data_ajax)
Source: stackoverflow.com
Related Query
- How to pass a JavaScript variable to JQuery
- Highcharts how to use JavaScript variable as series data source?
- how to make custom directive or pass variable in directive in angular js
- How to access angular scope variable in JavaScript file
- Highcharts how to pass milliseconds to pointStart (really a javascript question)
- How to Cache DOM Variable in jQuery
- how to pass template variables to javascript
- Highcharts not working when pass the javascript variable as hightcharts series data
- How to create a javascript column chart with overlapping columns of variable width
- pass global variable into jquery function
- How can I pass this array to a javascript function in an html.erb file, without erb evaluating the Date.UTC?
- How to pass a JSON through a variable to highchart heatmap data tag?
- How to make Javascript file use variable that was sent to Pug view
- How to use a javascript variable in highcharts series?
- How do I pass a PHP variable from one file to another multiple times?
- Use django variable (array of elements from sqlite3 database) inside javascript embedded code
- how to use javascript variable for complete series data
- How to pass variable values in series:[{data: }] object collection
- I cannot pass in a variable into the highcharts function using jquery and pug.
- Highchart how to use custom javascript variable in highchart?
- laravel 5 - pass php varaible to jquery or ajax or javascript
- How to pass the another variable to the Highchart basic line which should be dynamic
- How to pass JSP array to Javascript of highchart to generate a column chart
- How to display the value instead of percentage in a pie chart using jquery Highcharts
- How can I read an Excel File with JavaScript (without ActiveXObject)
- How do I dynamically change a data point in Highcharts using JavaScript
- How to get Render Performance for Javascript based Charting Libraries?
- Javascript Highcharts v3.0.5 - How to hide Y Axis Title when using multiple Y Axis
- Optimize JavaScript DrillDown code
- How to pass json data to highcharts series?
More Query from same tag
- Highchart columnrange, color code lines based on data
- TypeError: $(...).highcharts is not a function
- change particular line chart series colour dynamically in highcharts
- Vuejs Component Communication
- Highcharts - Pie Chart - link in tooltip
- Javascript creating an array in a flat format based on multiple levels
- highcharts stackLabels updating issue
- How to convert a JavaScript object to array
- Highcharts not displaying anything just blank html page
- rCharts shows limited functionality when used with Shiny 0.8.0.99
- R - Highcharter, How to avoid increasing the indentation of the y axis label?
- Highcharts Bar Chart Zoom not working
- Highcharts, how can I start xAxis on an arbitrary time
- Populate Highcharts X-Axis With Dates Given a From And To Date
- Is there a complete/ready event even if I turn off the animation effect for a HighChart instance?
- Framework for plotting latitude longitude in a map based on country, state and district depending on the zoom level
- Highcharts - Assign a color to a specific value when data is dynamic
- Highcharts stock chart overflow above of yAxis lable
- How to dynamically resize a highslide popup called from a Highchart graph using jquery?
- HighCharts: How to put the xAxis category text inside the chart
- Highcharts - Turning on and off gridlines on show, hide, or legendItemClick
- adding click event dynamically created highchart
- Primary Y Axis Scale not Working in Highcharts
- Highcharts - column chart has space between bar and xAxis
- How to change the color of single point in spiderweb chart
- Highcharts : hiding bottom-most x axis grid line
- pass global variable into jquery function
- How to make yAxis stackLabels under yAxis in Highcharts?
- Highchart generate array series
- highcharts display data from different months