我有以下代码,它运行良好:
$(document).ready(function() {
get_data_for_chart();
function get_data_for_chart() {
$.ajax({
url: 'get_data.aspx?rand=' + Math.random(),
type: 'GET',
dataType: 'json',
error: function(xhr, status, error) {
console.log(status);
console.log(xhr.responseText);
},
success: function(results) {
var chart1;
chart1 = new Highcharts.Chart( {
chart: {
renderTo: 'portlet_content_18',
defaultSeriesType: 'column'
}
});
}
});
}
});
HTML大致如下:
<div id="portlet_content_18">
用户可以动态选择他想要在屏幕上显示的“portlet”。他还可以选择多次在屏幕上显示相同的“portlet”以进行比较。
因此,如果最终HTML变成:
<div id="portlet_content_18">
<div id="portlet_content_18">
只有第一个 div
中出现了图表内容,而第二个则是空白的。我该如何解决这个问题?