简体   繁体   English

PHP Javascript Div刷新

[英]Php Javascript Div Refresh

I'm refreshing a div every 20 seconds on a page. 我每20秒刷新一次div。 The code refreshes the div but also nests a div inside of itself. 该代码刷新了div,但还在其内部嵌套了一个div。

<script>
  setInterval(function(){
  $("#open").load("test.php #open");
  }, 20000);
</script>

Before javascript reload: 在重新加载javascript之前:

<div id="open">
  <p>Testing</p>
</div>

After javascript reload: javascript重新加载后:

<div id="open">
    <div id="open">
        <p>Testing</p>
    </div>
</div>

No matter how long the page sites there it will always just have one nested div after the javascript runs. 不管页面站点在那里停留多长时间,在javascript运行之后,它始终只会有一个嵌套的div。 How do I get this to not load another nested div? 我如何才能不加载另一个嵌套的div?

I presume test.php returns <div id="open">(blah)</div> ? 我假设test.php返回<div id="open">(blah)</div>吗?

Try: 尝试:

$("#open").load("test.php #open").children( ).unwrap( );

Although you should really change the php script. 虽然您应该真正更改php脚本。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM