Take the 2-minute tour ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

i am trying to handle the "server side error codes" in angularjs like this but it is not working $timeout(function() { $scope.register.sales_total_amount=data2; salesregister.save($scope.register, function(data){ data1=data.sales_id; }, function(error,status){ if(error.status===404) { alert("DATA CANNOT BE INSERTED PLEASE CHECK YOUR VALUES!!!!"); } } ); }, 2000);

how can i handle the these server side errors???

share|improve this question
    
Why are using the $timeout wrapping and what problem are you facing handling server errors in error callback? –  Chandermani 22 hours ago
    
i have used $timeout because i am making couple of API calls to make sure that they will execute in a queue one by one, and i am trying to print a simple message on the error code of 404 as written in code but its not working even though i am getting the error code 404 from server. –  irfan shafi 21 hours ago
    
The server should return http status codes in 4xx or 5xx range to hit the error callback. –  Chandermani 20 hours ago
    
i know that sir but the above shown code is not working is there any other way to handle the errors or am i doing it in a right way ? –  irfan shafi 20 hours ago
    
In the browser console log see what http status code is returned? Is it 4xx or 5xx? –  Chandermani 18 hours ago

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.