以下是代码:
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("加载超时");//我这样设置的,但是没效果,请大家帮忙看看!``
}
});
})
问题:我用的是ng框架的ajax请求数据,然后想实现加载数据超过8秒后弹出报错 “加载超时”!
PHPz2017-05-15 17:11:17
Just add a timeout to your alert
setTimeOut(()=>alert('Timeout'),8000)
Is there anything else you want to do?