0
在页面的左侧我有一个链接列表,它们加载一个div块的页面被称为“包含”。加载块div Ajax
<div id="contenue"> </ div>.
在头节,我叫页面文件JS:
<script language="javascript" type="text/javascript" src="jabbax.js"></ script>.
对于链接必须是此类型:
<a href="#" onclick="javascript:getPage('chargement_div/details.php','contenue');"> left box </ a>.
的链路由以下JavaScript函数包含代码Js Ajax的文件,带有参数,页面名称以及将出现在页面中的div块的名称。
加载页面details.php
没有重新加载整个页面工作得很好。 问题:details.php页面包含一个不显示的JavaScript,换句话说,只有html代码显示在div中。
这是detail.php
<script type="text/javascript" >
var chartData = [
{country:"var1",litres:Math.round(<?php echo $pr_var1;?>)},
{country:"var2",litres:Math.round(<?php echo $pr_var2;?>)},
{country:"var3",litres:Math.round(<?php echo $pr_var3;?>)},
{country:"var4",litres:Math.round(<?php echo $pr_var4;?>)}];
window.onLoad=function() {
var chart = new AmCharts.AmPieChart();
chart.dataProvider = chartData;
chart.titleField = "country";
chart.valueField = "litres";
chart.depth3D = 10;
chart.angle = 12;
chart.labelRadius = -30;
chart.labelText = "[[value]]%";
chart.balloonText="[[title]] : [[value]]%"
chart.position = "center";
var legend = new AmCharts.AmLegend();
legend.position = "right";
legend.borderAlpha = 0.5;
legend.horizontalGap = 20;
legend.markerType = "circle";
legend.switchType = "x";
chart.addLegend(legend);
chart.write("chartdiv");
}
</script>
<div id="chartdiv" style="height:350px;position: relative;" ></div>
你能帮我的内容?
使用php include不能解决我的问题。 我想改变php页面的内容,而不用重新加载整个页面只是左边的div。 – Brawia
然后在你的php代码中确定你的代码是echod或不在php块中。如果你不熟悉herodoc和heredoc,它们是回显代码的非常有用的方法。你不必逃避任何东西。另外一些人在if语句中跳出php来回显代码。即<? if(statement){?> html code <?php} else {?> more html code – Yamiko