duano3557 2016-11-27 20:59
浏览 32

用[重复]内的php数据不断刷新<body>

This question already has an answer here:

So i have a webpage that constantly requires the output of a php file by for example adding this, there are multiple files that need to be loaded in different divs

<?php include('table1.php'); ?>

But i need it to be constantly loading every second, is there a better way to do this or how do i do this

</div>
  • 写回答

1条回答 默认 最新

  • dongqiao8417 2016-11-27 21:05
    关注

    You can very easily and effectively load data using jQuery. Here's some examples

    html

    <div id="mycontent">
    </div>
    

    JS load contents of a .php file

    var element = "#mycontent";
    var link = "script.php";
    $(element).load(link);
    

    JS load contents of a .php file after submitting POST

    var username = "test";
    $.post("script.php", {
    user:username
    }, function(responseData)
    {
        $('#mycontent').html(responseData);
    });
    

    And of course you can make functions out of these and call them either using setTimer loops, onclick events for buttons and many other ways.

    Keep in mind you need to include jQuery for these to work, and although it's possible using pure JS as well, jQuery is safer and much easier.

    评论

报告相同问题?

悬赏问题

  • ¥15 Vue3 大型图片数据拖动排序
  • ¥15 划分vlan后不通了
  • ¥15 GDI处理通道视频时总是带有白色锯齿
  • ¥20 用雷电模拟器安装百达屋apk一直闪退
  • ¥15 算能科技20240506咨询(拒绝大模型回答)
  • ¥15 自适应 AR 模型 参数估计Matlab程序
  • ¥100 角动量包络面如何用MATLAB绘制
  • ¥15 merge函数占用内存过大
  • ¥15 使用EMD去噪处理RML2016数据集时候的原理
  • ¥15 神经网络预测均方误差很小 但是图像上看着差别太大