不使用Ajax刷新div的内容 [英] Refresh content of a div without ajax

查看:56
本文介绍了不使用Ajax刷新div的内容的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个带id=mydiv的div,并且在此div内,我有一些内容可以在一段时间内从数据库中动态获取.

I have a div with id=mydiv and inside of this div I have some content that I am grab it dynamically from database with a while.

是否可以使用按钮来刷新或重新加载div的内容,而无需使用.load() ajax方法?

Is there any way to use a button to refresh or reload the content of my div without using .load() ajax method?

$("#mydiv").load("index.html")

示例:

<div id="mydiv">
<?php
$trtyb = mysql_query ("SELECT * FROM xxx WHERE xxx= '$getcat'");
while($fina = mysql_fetch_assoc($trtyb)) {
  echo $fina['name'];
  echo "<br>";
}
?>
</div>

推荐答案

您需要获取最新内容.唯一的方法就是使用http请求.发出http请求的唯一方法是:

You need to get the fresh content. The only way you can do it is with an http request. The only ways to make the http request are:

1)重新加载整个页面.

1) reloading the entire page.

2)使用ajax-如果您不希望延迟,这就是为什么您不想使用ajax,则可以设置一个JavaScript计时器,该计时器可以进行周期性的ajax调用并将数据连续更新为变量.然后,当用户单击按钮刷新数据时,您只需从存储的变量中提取数据即可.

2) using ajax - If you don't want a delay and that is why you don't want to use ajax, you could set up a javascript timer that would make periodic ajax calls and continuously update the data into a variable. Then when the user clicks the button to refresh the data, you can just pull the data from the stored variable.

3)将所有内容放入iframe中,并且需要对其进行刷新(我认为使用此内容没有任何好处).

3) put all of the content in an iframe, and that would need to be refreshed (I see no benefit to using this).

这篇关于不使用Ajax刷新div的内容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆