Unexpected response from server. The status code of response is ‘0’. The status text of response is ”

Recently while working with ECMASCRIPT I came across an issue that stated “Unexpected response from server. The status code of response is ‘0’. The status text of response is ”. Now, I got this error in the error logger list which is a custom list that we created to log any exceptions that arise.
To my utter surprise, I was not able to reproduce the issue at my local environment as well as production site and no complaints of any broken functionality also came from the client. But randomly this error was getting logged in the logger list. This made me think as to what could be the cause of the issue. I tried various ways to reproduce this error and voila, I was able to get to this error when I navigated to some other page before the asynchronous call that my ecmascript code was making had completed. I tried this a couple of times and everytime I navigated to the other page before the call had completed, I got this error logged in the logger. This way I could understand as to why this happened.
After some more analysis, I found out that status code 0 comes when you make an ajax call and refresh the page or navigate to some different page without getting the ajax response. So for all my dear friends out there, if you ever come across this random weird error, then probably it is because your asynchronous call was cancelled before getting the response. Hope it gives some pointer.

This entry was posted in Uncategorized. Bookmark the permalink.

Leave a comment