【问题标题】:jquery show loading image until page loaded in divjquery显示加载图像,直到页面加载到div中
【发布时间】:2015-08-02 19:10:02
【问题描述】:

我试图在每次页面加载到 div 时显示加载图像,但我没有看到加载图像。

我试过这个:

<img src="images/ajax-loader.gif" id="loading">

jquery:

$('#content').fadeOut('fast', function(){
    $('#loading').show();
    $('#content').load("about.php", function(){
        $('#content').fadeIn('slow');
        $('#loading').hide();
    });
});

【问题讨论】:

    标签: php jquery css


    【解决方案1】:

    将您的 &lt;img src="images/ajax-loader.gif" id="loading"&gt; 保留在 #content div 之外。

    【讨论】:

      【解决方案2】:

      在 about.php 之后,您的 jQuery 中缺少引号。

      这是修改后的 jQuery:

      $('#content').fadeOut('fast', function(){
          $('#loading').show();
          $('#content').load("about.php", function(){
               $('#content').fadeIn('slow');
               $('#loading').hide();
          });
      });
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2013-05-24
        • 1970-01-01
        • 1970-01-01
        • 2011-11-15
        • 1970-01-01
        • 2022-11-21
        相关资源
        最近更新 更多