简体   繁体   English

加载块div Ajax

[英]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块中加载的页面称为“包含”。

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

In the head section and I called the page file Js: 在开头部分,我将页面文件称为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. 该链接由包含代码Js Ajax的文件上的以下JavaScript函数组成,带有参数,页面名称和将出现在页面中的div块的名称。
loading the page details.php without reloading the entire page is working very well. 在不重新加载整个页面的情况下加载页面details.php效果很好。 PROBLEM: the details.php page contains a JavaScript that is not displayed, in other words, only the html code is displayed in the div. 问题:details.php页面包含未显示的JavaScript,换句话说,仅html代码显示在div中。

This is the content of detail.php 这是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>  

Can you help me ? 你能帮助我吗 ?

are you sure your echoing it? 您确定要回应吗? also the javascript wouldn't run if you just load it via ajax. 如果您只是通过Ajax加载javascript,它也不会运行。 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. 不知道如何让它在普通javascript中运行。我使用jQuery.Also,如果您不需要它作为Ajax,则可以使用php include。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM