.load()不适合我

时间:2014-06-30 11:24:27

标签: javascript jquery

我有一个简单的程序,每100毫秒刷新一次页面。但是,当我试图运行它时,我只是得到一个空白页面。这是我的HTML

<script type="text/javascript" src="http://ajax.googleapis.com/ajax/
libs/jquery/1.3.0/jquery.min.js"></script>
<script type="text/javascript">
var auto_refresh = setInterval(
function ()
{
$('#load_tweets').load('demo.php').fadeIn("slow");
}, 10000); // refresh every 10000 milliseconds

<body>
<div id="load_tweets"> </div>
</body>

</script>

请帮助我解决这个问题,因为我是jquery.Thanks的初学者

2 个答案:

答案 0 :(得分:1)

问题是关闭脚本标记 试试这个

<html>
<head>
<script src="http://ajax.googleapis.com/ajax/
libs/jquery/1.3.0/jquery.min.js"></script>
<script type="text/javascript">
var auto_refresh = setInterval(
function ()
{
$('#load_tweets').load('record_count.php').fadeIn("slow");
}, 10000); // refresh every 10000 milliseconds
</script>
</head>
<body>

<div id="load_tweets"></div>

</body>
</html>

答案 1 :(得分:0)

改为使用setTimeOut()。

setTimeout("yourfunction()", 1000);   // call yourfunction() after 1 second

function yourfunction(){

//do what you want
}

同样更正您的HTML!