在镀铬同步Ajax调用加载器不工作 [英] Loader not working during synchronous ajax call in chrome

查看:149
本文介绍了在镀铬同步Ajax调用加载器不工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在同步加载程序无法正常工作(异步:假的)在谷歌浏览器的AJAX调用。做工精细在Firefox和放大器; IE浏览器。在我的调试测试,装载机展示,直到ajax请求启动。越来越除名或消失时,请求发送到服务器上,我不停地调试点。我曾尝试过其他解决方案,如使用ajaxStart,beforeSend和放大器;阿贾克斯装载机等,但没有用。请提供有效的解决方案。

 < D​​IV ID =LoaderDiv的风格=显示:无>
    < IMG ID =ImageLoader的SRC =图像/ loading.gif/>
 < / DIV>
 


  $('#LoaderDiv)显示();
            $阿贾克斯({
                键入:POST,
                的contentType:应用/ JSON的;字符集= UTF-8,
                网址:servicePath,
                异步:假的,
                成功:功能(数据){
                    执行console.log(data.d);
                    $('#LoaderDiv)隐藏()。
                }
            });
 

解决方案

我试了一下在谷歌Chrome浏览器这是工作。可能如果您有任何其他错误或尝试发布更多code,如果你离开了一些code对你的问题进行检查。

检查code在的jsfiddle ,其工作正常。

我只加给你的code:

 错误:功能(数据){
                       $('#LoaderDiv)隐藏()。
               }
 


但是请注意,我说在错误处理功能,因为与出它的图像(您的 GIF )将永远显示时发生错误。 (如果你从服务器获取的任何错误响应,那么这将是一个解决方案)

Loader not working during a synchronous(Async:false) ajax call in google chrome. Working fine in Firefox & IE. During my debug testing, Loader showing until ajax request start. getting struck off or disappears when request sent to server, where I kept a debug point. I have tried other solutions like use of ajaxStart, beforeSend & ajax loader ect., But no use. Please give valid solution

 <div id="LoaderDiv" style="display: none">
    <img id="ImageLoader" src="Images/loading.gif" />
 </div>


            $('#LoaderDiv').show();
            $.ajax({
                type: "POST",
                contentType: "application/json; charset=utf-8",
                url: servicePath,
                async: false,
                success: function (data) {
                    console.log(data.d);
                    $('#LoaderDiv').hide();
                }
            });

解决方案

I tried it in google-chrome it is working. May be check if you have any other error or try to post more code if you are leaving out some code on your question.

check your code on jsfiddle, it is working.

I only added this to your code:

error: function(data){
                       $('#LoaderDiv').hide(); 
               }


But notice I added the error handle function because with out it the image ( your gif ) will show forever when error happens. ( If you were getting any error response from the server then this will be a solution)

这篇关于在镀铬同步Ajax调用加载器不工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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