2011-09-03 116 views
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> 

你能幫我的內容?

回答

0

你確定你的迴應嗎?如果你只是通過ajax加載它,javascript也不會運行。不知道如何讓它運行在普通的JavaScript我使用jQuery.Also,如果你不需要它是Ajax你可以使用PHP包括。

+0

使用php include不能解決我的問題。 我想改變php頁面的內容,而不用重新加載整個頁面只是左邊的div。 – Brawia

+0

然後在你的php代碼中確定你的代碼是echod或不在php塊中。如果你不熟悉herodoc和heredoc,它們是回顯代碼的非常有用的方法。你不必逃避任何東西。另外一些人在if語句中跳出php來回顯代碼。即<? if(statement){?> html code <?php} else {?> more html code Yamiko