I am making an ajax call using $http in angular js. I have implemented timeout in it. But I want to show the user an error message if the connection times out. The following is the code..
$http({
method: 'POST',
url: 'Link to be called',
data: $.param({
key:Apikey,
id:cpnId
}),
timeout : 5000,
headers: {'Content-Type': 'application/x-www-form-urlencoded'}
}).success(function(result){
alert(result);
}).error(function(data){
alert(data);
});
Is there any way so that I can display the user if the connection is timed out. Is there any way so that it can be configured at one place?