doushi7314 2016-09-13 01:05
浏览 30
已采纳

在PHP中使用javascript刷新div

So currently I am creating approve or deny page for several users in PHP and the page that I am building needs to be REFRESH

1.What I am trying to do is refreshing a SPECIFIC DIV

     The function refresh in javascript is working but there is
     a sudden duplication of div. 

I checked it several times and there is NO double(2) input="type" for search.

What line should I modify in to remove the duplicate SEARCH in div ref1 ?

  1. Can you guys please suggest an alternative way to refresh a div ?

enter image description here

<style>
           #ref2{
               background-color: darkseagreen;
           } #ref1{
               background-color: pink;
           }
       </style> 
    
 <body>
        <div id="ref1">
               shortcut preview **
              PHP -> isset ....add, delete, approve, search                       
               then view the content (SELECT * FROM dbname)  
               see image ^
   </div>


   <div id="ref2">
            <form action="tor.php" method="post">
              <input type="text" name="search" placeholder="Search for members.." onkeydown="searchq();" required  />
              <input type="submit" value=">>">
              <?php echo("$output"); ?>
           </form>         
      </div> 

<script langauge="javascript">
    function updateContent() {
    $.get("#", function(data) 
    { 
        $("#ref1").html( data ); 
        });
    }
        setInterval(updateContent, 1000);
    </script>
</body>
</html>

</div>
  • 写回答

2条回答 默认 最新

  • dongmi1864 2016-09-13 01:48
    关注

    you need to get the content of the ref1 div only to replace the previous content with, as you now get the entire HTML page and replace the div content with it.

    function updateContent() {
       $.get("#", function(data) 
       {
        var x = document.createElement("div"); 
            x.innerHTML = data;
           $("#ref1").html( $(x).find("#ref1").html()); 
        });
    }
        setInterval(updateContent, 1000);
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 求差集那个函数有问题,有无佬可以解决
  • ¥15 【提问】基于Invest的水源涵养
  • ¥20 微信网友居然可以通过vx号找到我绑的手机号
  • ¥15 寻一个支付宝扫码远程授权登录的软件助手app
  • ¥15 解riccati方程组
  • ¥15 display:none;样式在嵌套结构中的已设置了display样式的元素上不起作用?
  • ¥15 使用rabbitMQ 消息队列作为url源进行多线程爬取时,总有几个url没有处理的问题。
  • ¥15 Ubuntu在安装序列比对软件STAR时出现报错如何解决
  • ¥50 树莓派安卓APK系统签名
  • ¥65 汇编语言除法溢出问题