当我点击按钮时,我有以下jQuery代码
$('#substat').click(function() {
$.post('ext/engine.php', post, function(data){
$('#statout').empty().append(data).dialog(
{height:350, width:700, dialogClass: 'shadowme', position: 'center'})
});
});
更新 - 我已按代码检查代码以查看问题所在。看起来,它是PHP部分,如下所示:
$html = '<script>';
for($s = 0; $s < $m; $s++) {
if ($m-$s != 1) { $var1 .= $out[total][$s].', '; $var2 .= $out[age][$s].'", "'; }
else { $var1 .= $out[total][$s]; $var2 .= $out[age][$s].'"';}
if ($out[total][$s] > $max) { $max = $out[total][$s]; }
}
if ($max > 10) { $max = round($max/10); }
$html .= 'VarH = ['.$var1.'];
plot1 = $.jqplot("statout", [VarH], {
legend:{show:true, location:"ne"},
title:"Gente",
series:[ { label:"VarH", renderer:$.jqplot.BarRenderer } ],
axes:{
xaxis:{ renderer:$.jqplot.CategoryAxisRenderer, ticks:['.$var2.'] },
yaxis:{ min:0, tickInterval:'.$max.', autoscale: true }
},
seriesDefaults:{ lineWidth:5, rendererOptions: { barWidth:5, barMargin:5, barPadding:0 } }
});
</script>';
echo $html;
如果我将最后一行从 echo $ html; 更改为 echo“Hello”; 它将始终有效。
但是如果我把它与jqplot创建的$ html变量一起使用,它只会在jquery对话框中渲染一次。之后我必须重新刷新网页以使其再次工作,而不是再次单击提交按钮以创建包含图表的对话框。
答案 0 :(得分:2)
我遇到了同样的问题。解决方案是首先显示对话框,然后(!)将图表加载到。