angular.js - How to set the request time in $http.get().success() in ng? I want to make the request timeout effect!
为情所困
为情所困 2017-05-15 17:09:17
0
2
1172

Here is the code:

app.controller('salesCtrl',function($scope,$http,$rootScope){
            $scope.hasMore=true;
            $(".placeholderLoad").show();
            $http.get('data/sales.php',{timeout:8000}).success(function(data){
                //console.log(data);
                $scope.dishList=data;
                $(".placeholderLoad").hide();
            }).error(function(data,status){ //错误处理
                //console.log(data);
                //console.log(status);
                if(status=='timeout'){
                    alert("加载超时");//我这样设置的,但是没效果,请大家帮忙看看!``
                }
                
            });
})

Problem: I am using the ajax of the ng framework to request data, and then I want to realize that after loading the data for more than 8 seconds, an error "loading timeout" will pop up!

为情所困
为情所困

reply all(2)
PHPzhong

Just add a timeout to your alert
setTimeOut(()=>alert('Timeout'),8000)

Is there anything else you want to do?

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template