Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angularjs/25.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/spring-boot/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
从angularjs ajax调用获取数据时应用程序冻结_Angularjs - Fatal编程技术网

从angularjs ajax调用获取数据时应用程序冻结

从angularjs ajax调用获取数据时应用程序冻结,angularjs,Angularjs,我试图从angularjs$http服务中获取数据,在这个服务中,我使用了两个ajax调用(这些调用影响同一页面),但由于第二个调用,我的应用程序一直处于冻结状态,直到我没有收到该调用的响应为止 以下是我的controller.js代码:- $q.all([ //first ajax call $http({ method:"post", url:"/c

我试图从angularjs$http服务中获取数据,在这个服务中,我使用了两个ajax调用(这些调用影响同一页面),但由于第二个调用,我的应用程序一直处于冻结状态,直到我没有收到该调用的响应为止

以下是我的controller.js代码:-

$q.all([
            //first ajax call   
            $http({     
                    method:"post",
                    url:"/catalog.php",  //From here I am fetching one kind of data that I have to show on main page
                    data:parameter,                         
                    headers: {'Content-Type' : 'application/x-www-form-urlencoded'}                     
                }).success(function(data){                              

                    //some conditions to show main page data                                
                    //from here I am showing the content to main page           

                }),     
            ,
        ]).then(function(){                     

                        $timeout(function(){                        

                            //this is the second ajax call to get the another part of data                                  
                            $http({                         
                                    url:"/filter.php",      //second ajax call to get right side filter section data                    
                                    headers: {'Content-Type' : 'application/x-www-form-urlencoded'}                     
                                }).success(function(data){   

                                    //From here I am creating another div on the same page (Large data on the right side of the page)   
                                    //Due to this call my application is getting hanged until the response is completed



                                });                             

                        },100);                                                             

                });

我希望我的应用程序不应该因为第二个ajax调用而冻结,而应该在第一个ajax调用之后运行。现在,第二个ajax调用冻结了我的应用程序。

您应该检查浏览器中的开发工具s(),看看发生了什么

打开网络选项卡
。您的http调用应该在那里

您还可以打开时间线选项卡,查看通话的哪个部分花了这么长时间

考虑到您正在加载大量数据,我建议使用无限滚动


这只是加载ng repeat的可见部分,然后加载更多数据(如果向下滚动)。

是否将第二次呼叫的响应输入ng repeat?如果在每次ng repeat的迭代中都有大量数据和/或指令,浏览器将冻结直到完成。是的,我正在使用第二个ajax调用的响应中的ng repeat创建大型html。我如何解决这个问题,因为我必须在同一页面上显示数据,同时我还必须保持速度,这就是为什么我只是调用第一个ajax调用,以便用户在调用第二个ajax调用后可以看到数据,所以在后台,我可以使用第二个ajax调用响应创建html的另一部分。谢谢Lisa,但我不会在主要内容中加载这些数据。我正在同一个页面上创建另一个html,就像右边的菜单过滤器一样(我们通常在电子商务网站上看到过滤器)。在该过滤器上,我根据类别将数据加载到不同的accordion选项卡中。如果我删除了菜单过滤器,那么页面工作正常。但我也必须展示这个过滤器,这样用户才能过滤主要内容。我想我真的不明白为什么你需要这么多数据来过滤。如果没有延迟加载的可能性,您可以对“角度性能”进行一些研究,以找到加快加载速度的方法。