Javascript Jquery自动运行分页

Javascript Jquery自动运行分页,javascript,jquery,Javascript,Jquery,我使用jquery创建分页,该脚本工作正常,但我希望该脚本工作正常,并在自动模式下调用不同的页面: <script> $(document).ready(function(){ $("#article_load_favourites").load("indexer_favourites_news.php"); }); </script> <script> function pagination(id) { $("#article_load_favourit

我使用jquery创建分页,该脚本工作正常,但我希望该脚本工作正常,并在自动模式下调用不同的页面:

<script>

$(document).ready(function(){
$("#article_load_favourites").load("indexer_favourites_news.php");
});
</script>

<script>
function pagination(id)
{
$("#article_load_favourites").load("indexer_favourites_news.php?pg_d="+id);
}

$(文档).ready(函数(){
$(“#article_load_favorites”).load(“indexer_favorites_news.php”);
});
函数分页(id)
{
$(“#article_load_favorites”).load(“indexer_favorites_news.php?pg_d=“+id”);
}
///调用脚本函数

setInterval(function() {

pagination(i+1);

}, 4000);



</script>
setInterval(函数(){
分页(i+1);
}, 4000);
想法是加载脚本,从cero开始,在4秒之前进入第一页,在其他4秒之前进入另一页,并继续到最后,在这一点上,我尝试这样做,但没有工作

我需要运行这个分页脚本,从第1页转到最后一页,然后在其他时间重新分页


谢谢

当您调用
setInterval
时,我认为您的HTML尚未加载。尝试在
$(document).ready()函数中移动
setInterval

<script>

function pagination(id)
{
  $("#article_load_favourites").load("indexer_favourites_news.php?pg_d="+id);
}

$(document).ready(function() {
  $("#article_load_favourites").load("indexer_favourites_news.php");

  var i = 1;

  setInterval(function() {
    pagination(i+1);
  }, 4000);
});

</script>

函数分页(id)
{
$(“#article_load_favorites”).load(“indexer_favorites_news.php?pg_d=“+id”);
}
$(文档).ready(函数(){
$(“#article_load_favorites”).load(“indexer_favorites_news.php”);
var i=1;
setInterval(函数(){
分页(i+1);
}, 4000);
});