在镀铬同步Ajax调用加载器不工作镀铬、加载、工作、Ajax

2023-09-10 14:51:16 作者:我比黄瓜更懂女人

在同步加载程序无法正常工作(异步:假的)在谷歌浏览器的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)隐藏()。
               }
 
Docker的工作原理

但是请注意,我说在错误处理功能,因为与出它的图像(您的 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)