日期:2014-05-16  浏览次数:20790 次

jquery使用load进行局部刷新没有效果
我的代码

<html>
<head>
<meta charset="utf-8">
<title>无标题文档</title>
<script src="http://code.jquery.com/jquery-2.0.3.js"></script>
<script language="javascript">
function reloa()
{
 $("#content").load(location.href+"#content<*","");
}
setInterval('reloa()',5000);
</script>

</head>

<body >
<!-- 建立底部层-->
<div id="content" name="de">
<script type="text/javascript">
var date=new Date();
var sec=date.getSeconds();
document.write("    "+sec);
</script>


<script type="text/javascript" src="http://hq.sinajs.cn/list=sh601006" charset="gb2312">

</script>

 <script type="text/javascript">

 var elements=hq_str_sh601006.split(",");

document.write("current price:"+elements[3]);

</script>

</div>
</body>
</html>



需求:每5秒刷新一次div id为content中的内容,就是每5秒执行一次id为content中的代码

我写的这段代码貌似没有作用,我想通过局部刷新的方式实现,每5秒对content中的javascript代码执行一次
------解决方案--------------------
应该是你其他的js 问题。直接调用可以的/
<html>
<head>
<meta charset="utf-8">
<title>无标题文档</title>
<script src="http://code.jquery.com/jquery-2.0.3.js"></script>
<script language="javascript">
function reloa()
{
  alert("1");
 $("#content").load(location.href+"#content<*","");
}
setInterval('reloa()',5000);
</script>

</head>

<body >
<!-- 建立底部层-->
<div id="content" name="de">
</div>
</body>
</html>