【问题标题】:Loading a block div Ajax加载块 div Ajax
【发布时间】:2011-09-03 11:22:22
【问题描述】:

在页面的左侧我有一个链接列表,它们在 div 块中加载一个页面,称为“包含”。

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

在head部分,我调用了页面文件Js:

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

对于链接必须是这种类型:

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

该链接由包含代码 Js Ajax 的文件上的以下 JavaScript 函数组成,带有参数、页面名称以及将出现在页面中的 div 块的名称。
在不重新加载整个页面的情况下加载页面details.php 运行良好。 问题:details.php 页面包含一个不显示的 JavaScript,换句话说,div 中只显示了 html 代码。

这是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>  

你能帮帮我吗?

【问题讨论】:

    标签: javascript ajax jquery php-5.3


    【解决方案1】:

    你确定你在呼应它吗?如果您只是通过 ajax 加载它,javascript 也不会运行。不知道如何让它在纯 javascript 中运行我使用 jQuery.Also 如果你不需要它是 ajax 你可以使用 php 包含。

    【讨论】:

    • 使用 php include 并不能解决我的问题。我想更改 php 页面的内容,而无需重新加载整个页面,只是左侧 div。
    • 然后在您的 php 代码中确保您的代码在 php 块中被回显或不在。如果你不熟悉 herodoc 和 heredoc,它们是非常有用的回显代码的方法。你不必逃避它们中的任何东西。此外,有些人在 if 语句中跳出 php 以回显代码。即 if(statement){ ?>html 代码 更多 html 代码
    猜你喜欢
    • 1970-01-01
    • 2015-10-25
    • 1970-01-01
    • 1970-01-01
    • 2013-06-03
    • 2011-10-23
    • 2013-07-10
    • 1970-01-01
    • 2011-08-02
    相关资源
    最近更新 更多