Wednesday, 7 August 2013

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.

8 comments:

  1. I encountered a similar problem and was scratching my head until I saw your post. In my case, the situation is only slightly different. This message appeared when the Internet connection to the SharePoint site dropped before the AJAX call completed. Thanks for pointing me in the right direction.

    ReplyDelete
  2. Big relief, I have the same logger list setup and am getting thousands of these errors logged.

    ReplyDelete
  3. Faced the same issue this was really helpful. Thank you

    ReplyDelete
  4. Replies
    1. This issue was coming only when I was navigating to a different page or refreshing a page before the ajax response. This is not an error as such and therefore I did not do anything around it. If you are logging it in the error logger list and don't want your logger list to be flooded with this error, then wherever you are writing the code to log to the list on error, simply do a if condition check on the status of the error code. If it is 0 then do not log that as it is not an error.

      Delete
  5. I have suffered the same issue, i was loading webpart properties from the webpart definition collection and some times i get the same error. Can you please let us know how to deal with it?

    ReplyDelete
    Replies
    1. This issue was coming only when I was navigating to a different page or refreshing a page before the ajax response. This is not an error as such and therefore I did not do anything around it. If you are logging it in the error logger list and don't want your logger list to be flooded with this error, then wherever you are writing the code to log to the list on error, simply do a if condition check on the status of the error code. If it is 0 then do not log that as it is not an error.

      Delete