varmyApp=angular.module("myApp",[]);myApp.config(['$httpProvider',function($httpProvider){var$http,interceptor=['$q','$injector',function($q,$injector){functionsuccess(response){// get $http via $injector because of circular dependency problem$http=$http||$injector.get('$http');if($http.pendingRequests.length<1){console.log('ajax cal respond with success');}returnresponse;}functionerror(response){console.log('x',response);// get $http via $injector because of circular dependency problem$http=$http||$injector.get('$http');if($http.pendingRequests.length<1){console.log('ajax call respond with error');}return$q.reject(response);}returnfunction(promise){console.log('before send ajax request');returnpromise.then(success,error);};}];$httpProvider.responseInterceptors.push(interceptor);}]);