controller:
app.run(function ($rootScope, $templateCache) {
$rootScope.$on('$viewContentLoaded', function ($scope, $http) {
$templateCache.removeAll();
alert("refreshing.....");
$http({
url: '/angularjs-restful/check/check-session',
method: "POST",
data: {},
isArray: false
}).success(function(data, status, headers, config){
alert("AJAX call successful.....");
console.log('status code: ' + status);
console.log('returned data: ' + data);
}).error(function(data, status, headers, config){
alert('An error occurred');
});
alert("end of function.....");
});
});
Is there a way to make an AJAX call when the user refreshes the page either by pressing F5 or manually refreshing with a mouse click? The URL points to a REST service that returns either true or false.