开发者

Loading a block div Ajax

On the left of the page I have a list of links, they load a page in a div block is called "contained".

<div id="contenue"> </ div>.  

In the head section and I called the page file Js:

<script language="javascript" type="text/javascript" src="jabbax.js"></ script>.  

For links must be of this type:

<a href="#" onclick="javascript:getPage('chargement_div/details.php','contenue');"> left box </ a>.  

The link consists of following JavaScript function on the file containing the code Js Ajax, with a parameter, the name of the page, and name of the div block which will appear in the page.

loading the page details.php without reloading the entire page is working very well. PROBLEM: the details.php page contains a JavaScript that is not displayed, in other words, only the html code is displayed in the div.

This is the content of detail.php

<script type="text/javascript" >
var chartData = [ 
{country:"var1",litres:Math.round(<?php echo $pr_var1;?>)},
{country:"var2",litres:Math开发者_StackOverflow.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>  

Can you help me ?


are you sure your echoing it? also the javascript wouldn't run if you just load it via ajax. not sure how to get it to run in plain javascript I use jQuery.Also if you dont need it to be ajax you can use a php include.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜