ajax图像加载器在Firefox中工作但不在谷歌浏览器中工作

Rab*_* Ko 7 javascript php ajax jquery

请帮助我在Chrome中调用ajax时无法显示加载图像?这是我的剧本

function ajx_load_image(category)
{
    $("#"+category+"-text-1 .loading").show(); // showing image

    $.ajax({
             type:'POST', 
             url: './img_load.php',
             data: {num_count:load_count,cat:category},
             async: false,

            success: function(data)
            {
                data=jQuery.trim(data);
                if(data != ''){                 
                    $("#"+category+"-text-1 .loading").hide();

                    $("#"+category+"-text-1 .items").append(data);
            }
            else{
                $('.next.browse.right.'+category).removeClass('disabled');                                      
            }

            }

        });
}
Run Code Online (Sandbox Code Playgroud)

我的html文件

<div id="tamil-text-1" class="tab-content">
  <div class="tab-top-curve"><img src="images/tab-top-curve.jpg" width="700" height="19" /></div>
  <div class="tab-mid-curve"> <a class="prev browse left disabled tamil" name="tamil"></a>
    <!-- root element for scrollable -->
    <div class="loading"><img src='images/ajax-loader.gif' /></div>
    <div class="scrollable">
      <!-- root element for the items -->
      <div class="items"> </div>
    </div>
    <!-- "next page" action -->
    <a class="next browse right tamil" name="tamil"></a> </div>
  <div class="tab-top-curve"><img src="images/tab-bottom-curve.jpg" width="700" height="31" /></div>
</div>
Run Code Online (Sandbox Code Playgroud)

我也在stackoverflow中访问了同样的问题,但我无法做到.

任何帮助将不胜感激.

Jai*_*Jai 1

我不确定,但这可能会有所帮助。尝试在函数中显示图像$.ajaxStart()并隐藏,$.ajaxComplete()因为当它成功时,它会很快隐藏图像:

\n\n
function ajx_load_image(category){\n\n    $.ajax({\n     \xc2\xa0  type:\'POST\', \n    \xc2\xa0\xc2\xa0\xc2\xa0\xc2\xa0url: \'/img_load.php\', //<------------------here \'.\' single dot removed\n    \xc2\xa0\xc2\xa0\xc2\xa0\xc2\xa0data: {num_count:load_count,cat:category},\n    \xc2\xa0\xc2\xa0\xc2\xa0\xc2\xa0async: false,\n        beforeSend: function(){\n           $("#"+category+"-text-1 .loading").show(); // showing image\n        },\n    \xc2\xa0\xc2\xa0\xc2\xa0\xc2\xa0success: function(data){\n        data=jQuery.trim(data);\n        if(data != \'\'){                 \n                $("#"+category+"-text-1 .items").append(data);\n        }else{\n            $(\'.next.browse.right.\'+category).removeClass(\'disabled\');                                      \n        }\n\n        },\n        complete: function(){\n            $("#"+category+"-text-1 .loading").hide();\n        }\n\n     });\n\n}\n
Run Code Online (Sandbox Code Playgroud)\n\n

更新:

\n\n

您可以用于beforeSend : function(){}显示加载图像,也complete: function(){}可以用于隐藏加载图像。

\n