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!
Just add a timeout to your alert
setTimeOut(()=>alert('Timeout'),8000)
Is there anything else you want to do?