Jquery Ajax在获取数据的同时加载图像

我在点击事件中使用 Jquery Ajax函数数据库获取数据.

功能正常工作并显示数据.
但是加载数据需要时间,因此我想在获取数据的同时放置加载图像.
我用这种方法来做

<script type="text/javascript">
    jQuery(function($) {
        $(document).ready(function() {
            $("#imgs").hide();
            $(".letter").bind('click',function(){
                $("#imgs").fadeIn();
                var val = $(".letter").val;
                var site = '<?PHP echo site_url(); ?>';
                $.ajax({
                    url: site+'/wp-content/themes/premiumnews/newContent.PHP?letter='+$(this).html(),success:function(data){
                        $("#imgs").hide();
                        $("#content1").html(data);
                    }
                });
            });
        });
    });
</script>

当我点击按钮时,会出现加载图像,但成功后图像应该消失,在我的情况下它仍然存在

我的代码错了吗?或者我使用了错误方法

解决方法

这是我过去一直使用的:

$('#loading_div').hide().ajaxStart(function(){
    $(this).show();
}).ajaxStop(function() {
    $(this).hide();
});

相关文章

页面搜索关键词突出 // 页面搜索关键词突出 $(function () {...
jQuery实时显示日期、时间 html: &lt;span id=&quot...
jQuery 添加水印 &lt;script src=&quot;../../../.....
中文:Sys.WebForms.PageRequestManagerParserErrorExceptio...
1. 用Response.Write方法 代码如下: Response.Write(&q...
Jquery实现按钮点击遮罩加载,处理完后恢复 思路: 1.点击按...