401 means unauthorized request. MVC framework will automatically look for this in your app and will redirect you(302=redirect) to your unauthorized error page. And then will return this page (200 = success). So that means you will end up in success callback and instead of your PartialView with updated entities you will get your unauthorized page. So how to override this default behaviour?

This solution is not 100% bullet proof. If you look on the code. It basically check your response and if there is 302 code (redirect) and also it is ajax call. It will change the status code to 401(unauthorized). So there might be case in you app where you want to return 302 code and this piece of code would break it. In such case you would have to use some kind of identifier that would differentiate those responses.

Summary

You should always add at least some general error handling for your ajax calls. It will help you to debug and test your application and it will help your users to identify that there is something wrong in case of error.