刷新Div的内容

时间:2017-03-29 11:36:41

标签: php jquery html slideshow

我已阅读了多篇关于通过使用Jquery重新加载div内容的帖子。我有一个带有多个浮动div的仪表板,可以旋转在php脚本中计算的数据。

即。我有一个PHP脚本,计算数据,我把它包含在div中,然后滚动内容(见下面的代码)

我在线提供的代码示例存在的问题是它没有显示我的php内容。

如何重新加载div中的php页面并仍然保持幻灯片显示?

提前致谢

<div class="topdiv_1">
    <div id="topdiv_1_slideshow">
        <div align="center">
            <img src="images/elements/project.png" class="pull-left" alt="" height="100px" style="padding-left: 10px; margin-top: 50px;">
            <h1 style="font-size: 90px; color: #ffffff; font-weight: bold"><?php include_once('topdiv_1_stat1.php') ?></h1>
            <h6 style="font-size: 14px; color: #ffffff; font-weight: bold">Project Hours Total</h6>
        </div>
        <div align="center">
            <img src="images/elements/project.png" class="pull-left" alt="" height="100px"
                 style="padding-left: 10px; margin-top: 50px;">

            <h1 style="font-size: 90px; color: #ffffff; font-weight: bold"><?php include_once('topdiv_1_stat2.php') ?></h1>
            <h6 style="font-size: 14px; color: #ffffff; font-weight: bold">Project Hours System Center</h6>
        </div>
        <div align="center">
            <img src="images/elements/project.png" class="pull-left" alt="" height="100px"
                 style="padding-left: 10px; margin-top: 50px;">

            <h1 style="font-size: 90px; color: #ffffff; font-weight: bold"><?php include_once('topdiv_1_stat3.php') ?></h1>
            <h6 style="font-size: 14px; color: #ffffff; font-weight: bold">Project Hours Service Center</h6>
        </div>
    </div>
</div>

更新:

我尝试将此代码添加到div中,但现在它抛弃了返回值的格式:

<div id="topdiv_1_slideshow">
        <div align="center" id="1">
            <img src="images/elements/project.png" class="pull-left" alt="" height="100px" style="padding-left: 10px; margin-top: 50px;">
            <h1 style="font-size: 90px; color: #ffffff; font-weight: bold"><?php /*include_once('topdiv_1_stat1.php') */?>
                <script>
                    $(function(){
                    $("#1").load("topdiv_1_stat1.php");
                    });
                </script>

                </h1>
            <h6 style="font-size: 14px; color: #ffffff; font-weight: bold">Project Hours Total</h6>
        </div>

2 个答案:

答案 0 :(得分:0)

您可以使用Ajax调用php脚本,获取数据并显示PHP脚本在您想要的DOM元素中返回的所有数据,这将使用新数据刷新它。

但是如果没有javascript,你就无法刷新页面的一部分。

答案 1 :(得分:0)

您的代码:

$("#1").load("topdiv_1_stat1.php");

将加载topdiv_1_stat1.php脚本的原始输出。

这意味着不会像在浏览器中打开页面时那样加载该响应中样式表的链接。

确保您的脚本“topdiv_1_stat1.php”仅返回您想要在#1 div中的html。