正如我在标题中提到的,我想将一个 Javascript 变量传递给 JQuery。我花了一整天的时间寻找方法,但一无所获。我尝试使用 ajax 将变量传递给 PHP,然后我可以获得响应数据。但是当我想将它传递给highcharts时,它不起作用,谁能告诉我如何做到这一点?我将不胜感激。
//this is the ajax I used to send the request to PHP , I can get the data in data_ajax.
function chooseCategory(mat_id){
var ajax = ajaxObj("POST", "test.php");
ajax.onreadystatechange = function() {
if(ajaxReturn(ajax) == true) {
data_ajax = ajax.responseText;
alert(data_ajax);}
}
ajax.send("id=" + material_id);
}
//this is part of the jquery code, the charts can not get any data from variable data_ajax.
$(function () {
$('#container3').highcharts({
...
...
series: [{ type: 'line', name: '#numbers:', data: data_ajax