douyu1656 2017-03-29 11:36
浏览 748
已采纳

刷新Div的内容

I have read through multiple posts regarding reloading the content of a div through the use of Jquery. I have a Dashboard with multiple floating divs that rotates data calculated in php scripts.

ie. i have a php script that calculates data and i include this in a div which then scrolls through the content (see below code)

The problem i have with the code examples available online is that it doesnt show my php content.

How can i go about reloading the php pages in the div and still keep my slideshow going?

Thanks in advance

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

UPDATE:

I have tried adding this code to the div but now it throws away the formatting of the returned value:

<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条回答 默认 最新

  • dongmu7335 2017-03-29 12:19
    关注

    Your code:

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

    will load the raw output of the topdiv_1_stat1.php script.

    That means that links to stylesheets in that response will not be loaded as they would when you open the page in your browser.

    Make sure your script "topdiv_1_stat1.php"only returns the html that you want in the #1 div.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 metadata提取的PDF元数据,如何转换为一个Excel
  • ¥15 关于arduino编程toCharArray()函数的使用
  • ¥100 vc++混合CEF采用CLR方式编译报错
  • ¥15 coze 的插件输入飞书多维表格 app_token 后一直显示错误,如何解决?
  • ¥15 vite+vue3+plyr播放本地public文件夹下视频无法加载
  • ¥15 c#逐行读取txt文本,但是每一行里面数据之间空格数量不同
  • ¥50 如何openEuler 22.03上安装配置drbd
  • ¥20 ING91680C BLE5.3 芯片怎么实现串口收发数据
  • ¥15 无线连接树莓派,无法执行update,如何解决?(相关搜索:软件下载)
  • ¥15 Windows11, backspace, enter, space键失灵