.ajaxStart和.ajaxStop不触发 [英] .ajaxStart and .ajaxStop not firing

查看:99
本文介绍了.ajaxStart和.ajaxStop不触发的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有人可以帮我理解这是为什么不工作?而阿贾克斯.load加载页的loading.gif出现,但不会永远消失。这使我相信,无论是.ajaxStart也不.ajaxStop函数被调用(因为它也没有隐瞒它最初其一)。

TIA!

CSS的:

  #loadingDiv {
背景图像:网址(图像/ loading.gif');
高度:32PX;
宽度:32PX;
保证金:50像素自动50px的汽车; }
 

jQuery的:

 <脚本类型=文/ JavaScript的>
        $(文件)。就绪(函数()
            {
                $('#loadingDiv)
                    。隐藏()
                    .ajaxStart(函数(){
                        $(本).show();
                    })
                    .ajaxStop(函数(){
                        $(本).hide();
                    })
                ;
                $(#结果)的负载(I / getAllInfo.class.php)。返回false;
            };
    < / SCRIPT>
 

解决方案

您不必从文件准备函数返回false,但你需要添加右括号),这样

  $(#结果)的负载(I / getAllInfo.class.php)。返回false;
 }); //< -----你需要的)
 

您的网址我/ getAllInfo.class.php看起来是错误的。

尝试注释掉$(本).hide()在.ajaxStop()是这样的:

  .ajaxStop(函数(){
     // $(本).hide();
})
 

由于其可能为它显示了这么短的时间,你不会看到它。

继承人捣鼓你: http://jsfiddle.net/GrsRT/11/

Can someone please help me understand why this isn't working? The loading.gif appears while the ajax .load is loading the page, but doesn't ever go away. This leads me to believe that neither the .ajaxStart nor the .ajaxStop functions are being called (because it's also not hiding it initially either).

TIA!

The css:

#loadingDiv {
background-image: url('images/loading.gif');
height: 32px;
width: 32px;
margin: 50px auto 50px auto; }

The jquery:

<script type="text/javascript">
        $(document).ready(function()
            {
                $('#loadingDiv')
                    .hide()
                    .ajaxStart(function() {
                        $(this).show();
                    })
                    .ajaxStop(function() {
                        $(this).hide();
                    })
                ;
                $("#results").load("i/getAllInfo.class.php"); return false;
            };
    </script>

解决方案

you don't need to return false from the document ready function but you do need to add the closing parenthesis ) like this

     $("#results").load("i/getAllInfo.class.php"); return false;
 }); //<----- you need the )

your url "i/getAllInfo.class.php" looks wrong.

try commenting out $(this).hide() in the .ajaxStop() like this:

.ajaxStop(function() {
     //$(this).hide();
})

Because its possible for it to show for so little time that you won't see it.

heres a fiddle for you: http://jsfiddle.net/GrsRT/11/

这篇关于.ajaxStart和.ajaxStop不触发的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆