0

我是 jQuery 新手,不知道如何成功运行我在页面中使用的脚本。问题是只有当我的load.php文件发生变化时我才需要淡入和淡出文本,但不像现在这样经常出现,请帮助任何人......非常感谢!

这是我的代码:

    $(document).ready( function(){
$('#auto').load('load.php');

refresh();

});



function refresh()
{

    setTimeout(function() {


      $('#auto').fadeOut('fast').load('load.php').fadeIn('fast');

      refresh();
       }, 2000);

   }
4

1 回答 1

0

尝试这个:

function refresh()
{
  setTimeout(function() {
    $.get('load.php', function(data) {
      if (data !== $('#auto').html()) {
         $('#auto').fadeOut('fast').html(data).fadeIn('fast');
      }
      refresh();
    });
  }, 2000);
}

这使得请求在 之外load(),并且只有淡入/淡出 + 替换不同的内容。

于 2018-11-16T11:08:53.500 回答