I've only done a quick skim of the code, but my initial suggestion would be to give the $interval service (instead of setInterval and clearInterval) a try: https://docs.angularjs.org/api/ng/service/$interval -- David Raynes http://rayners.org/ [email protected] I am just a figment of my own imagination.
On Thu, Dec 11, 2014 at 4:54 PM, Mukesh Malviya <[email protected]> wrote: > Hi team, > > getting this error > > code: > var myInterceptor = { > request: function(config) { > $rootScope.sessionExpireMessage =""; > //////console.log('request :::: $log is here to show you that this is a > regular factory with injection'); > config.requestTimestamp = new Date().getTime(); > $rootScope.sessionCount = $rootScope.sessionTO; > setCookie('sessionCount', > $rootScope.sessionCount,$rootScope.sessionTO); > // ////console.log(config.url); > $rootScope.serverTime = getCookie('serverTime'); > $rootScope.serverTime = $rootScope.serverTime==null ? null : > Math.abs($rootScope.serverTime); > $rootScope.clientTimeOffset = (new Date()).getTime() - > $rootScope.serverTime; > > if(getCookie('sessionCount') != 0){ > setCookie('clientTimeOffset', > $rootScope.clientTimeOffset,$rootScope.sessionTO); > $rootScope.userCookie = getCookie('user'); > } > $rootScope.sessionExpireMsg = true; > return config; > }, > response: function(response) { > > clearInterval($rootScope.timer); > > > if( $rootScope.userCookie == "" || $rootScope.userCookie == undefined || > $rootScope.userCookie == null || $rootScope.userCookie =='null'){ > $rootScope.sessionExpireMsg = true; > }else{ > //////console.log($rootScope.clientTimeOffset); > response.config.responseTimestamp = new Date().getTime(); > // ////console.log('response :::: $log is here to show you > that this is a regular factory with injection'); > > // ////console.log(response.config); > $rootScope.timer = setInterval(function(){ > $rootScope.userCookie = getCookie('user'); > if( $rootScope.userCookie == "" || $rootScope.userCookie == > undefined || $rootScope.userCookie == null || $rootScope.userCookie > =='null'){ > //console.log("User obj is not in cookie."); > clearInterval($rootScope.timer); > setCookie('sessionCount', 0,0); > delete $cookieStore.remove('user'); > $rootScope.show_login(); > } > //$rootScope.sessionCount = getCookie('sessionCount'); > if(getCookie('sessionCount') == $rootScope.sessionTO){ > ////console.log(response.config); > $rootScope.sessionCount = getCookie('sessionCount'); > } > > > $rootScope.sessionCount--; > > > $rootScope.sessionExpireMessage = "Your session will expire > in "+$rootScope.sessionCount+" seconds."; > > $rootScope.$apply(); > $rootScope.sessionExpireMsg = true; > > if($rootScope.sessionCount < 30){ > $rootScope.sessionExpireMsg = false; > }else{ > $rootScope.sessionExpireMsg = true; > } > ////console.log($rootScope.sessionCount); > > $rootScope.sessionExpiry = Math.abs(getCookie('sessionExpiry')); > $rootScope.timeOffset = Math.abs(getCookie('clientTimeOffset')); > > $rootScope.localTime = (new Date()).getTime(); > > if (($rootScope.localTime - $rootScope.timeOffset) > > ($rootScope.sessionExpiry - 10000) || $rootScope.sessionCount == 1 || > (getCookie('sessionCount') == 0)) { // 15 extra seconds to make sure > clearInterval($rootScope.timer); > setCookie('sessionCount', 0,0); > delete $cookieStore.remove('user'); > //setCookie('user',""); > $rootScope.sessionExpireMessage = "Your Session has Expired."; > $injector.invoke(function($http) { > > $http.post(strContextPathvm+"userLoginServices/logout",$rootScope.userRespObj). > success(function(data, status, headers, config) { > $rootScope.show_login(); > // successCallback(data,status,headers,config); > }). > error(function(data, status, headers, config) { > throw { message: 'ERROR: Could not get data.', }; > }); > }); > /*$http.get('/someUrl'). > success(function(data, status, headers, config) { > // this callback will be called asynchronously > // when the response is available > }). > error(function(data, status, headers, config) { > // called asynchronously if an error occurs > // or server returns response with an error status. > });*/ > > > } else{ setCookie('sessionCount', > $rootScope.sessionCount,$rootScope.sessionCount);} > }, 1000); > } > return response; > }, > responseError: function(response) { > if (response.status == 500 || response.status == 404 || > response.status == 417){ > if(response){ > if(response.data){ > if(response.data.message){ > > //console.log(response); > //console.log(response.data.message); > $rootScope.globalErrorMessage = "Error : > "+response.data.message; > $rootScope.globalErrorCSS = "error1"; > $rootScope.isErrorPage = true; > $rootScope.show_errorPage(); > } > } > } > } > return $q.reject(response); > } > > }; > return myInterceptor; > }]); > > Error:- > > Error: [$rootScope:infdig] > http://errors.angularjs.org/1.2.20/$rootScope/infdig?p0=25&p1=%5B%5BNaNn%3A%function%20()%7Bvar%20a%3Dd.url()%2Cb%3Dk.%24%24replace%3Bn%26%26a%3D%3Dk.absUrl()%7C%7C%5Cn(n%2B%2B%2Cc.%24evalAsync(function()%7Bc.%24broadcast(%5C%22%24locationChangeStart%5C%22%2Ck.absUrl()%2Ca).defaultPrevented%3Fk.%24%24parse(a)%3A(d.url(k.absUrl()%2Cb)%2Cf(a))%7D))%3Bk.%24%24replace%3D!1%3Breturn%20n%7D%3B%20newVal%3A%2023%3B%oldVal%3A%2022%22%5D%2C%5B%fn%3A%function%20()%7Bvar%20a%3Dd.url()%2Cb%3Dk.%24%24replace%3Bn%26%26a%3D%3Dk.absUrl()%7C%7C%5Cn(n%2B%2B%2Cc.%24evalAsync(function()%7Bc.%24broadcast(%5C%22%24locationChangeStart%5C%22%2Ck.absUrl()%2Ca).defaultPrevented%3Fk.%24%24parse(a)%3A(d.url(k.absUrl()%2Cb)%2Cf(a))%7D))%3Bk.%24%24replace%3D!1%3Breturn%20n%7D%3B%20newVal%3A%2024%3B%oldVal%3A%2023%22%5D%2C%5B%fn%3A%function%20()%7Bvar%20a%3Dd.url()%2Cb%3Dk.%24%24replace%3Bn%26%26a%3D%3Dk.absUrl()%7C%7C%5Cn(n%2B%2B%2Cc.%24evalAsync(function()%7Bc.%24broadcast(%5C%22%24locationChangeStart%5C%22%2Ck.absUrl()%2Ca).defaultPrevented%3Fk.%24%24parse(a)%3A(d.url(k.absUrl()%2Cb)%2Cf(a))%7D))%3Bk.%24%24replace%3D!1%3Breturn%20n%7D%3B%20newVal%3A%2025%3B%oldVal%3A%2024%22%5D%2C%5B%fn%3A%function%20()%7Bvar%20a%3Dd.url()%2Cb%3Dk.%24%24replace%3Bn%26%26a%3D%3Dk.absUrl()%7C%7C%5Cn(n%2B%2B%2Cc.%24evalAsync(function()%7Bc.%24broadcast(%5C%22%24locationChangeStart%5C%22%2Ck.absUrl()%2Ca).defaultPrevented%3Fk.%24%24parse(a)%3A(d.url(k.absUrl()%2Cb)%2Cf(a))%7D))%3Bk.%24%24replace%3D!1%3Breturn%20n%7D%3B%20newVal%3A%2026%3B%oldVal%3A%2025%22%5D%2C%5B%fn%3A%function%20()%7Bvar%20a%3Dd.url()%2Cb%3Dk.%24%24replace%3Bn%26%26a%3D%3Dk.absUrl()%7C%7C%5Cn(n%2B%2B%2Cc.%24evalAsync(function()%7Bc.%24broadcast(%5C%22%24locationChangeStart%5C%22%2Ck.absUrl()%2Ca).defaultPrevented%3Fk.%24%24parse(a)%3A(d.url(k.absUrl()%2Cb)%2Cf(a))%7D))%3Bk.%24%24replace%3D!1%3Breturn%20n%7D%3B%20newVal%3A%2027%3B%oldVal%3A%2026%22%5D%5D > at Error (native) > at http://localhost:8080 > > -- > You received this message because you are subscribed to the Google Groups > "AngularJS" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > To post to this group, send email to [email protected]. > Visit this group at http://groups.google.com/group/angular. > For more options, visit https://groups.google.com/d/optout. -- You received this message because you are subscribed to the Google Groups "AngularJS" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/angular. For more options, visit https://groups.google.com/d/optout.
