When I'm looking at a good question I can't answer I will often upvote it and immediately click on the SO logo to go back to the homepage. What then happens, in very quick succession, is:
- The upvote button turns orange, which indicates to me that the vote succeeded.
- An error message box appears: "An error has occurred - please try again"
- The homepage loads.
If I cared at all about that vote I then have to click back, click the vote button again, wait a little bit to be safe, then click the homepage link again. This happens to me at least twice a day and it's quite annoying.
Having implemented such AJAX requests myself I have a pretty good idea of what's happening: the AJAX request fails because the page is being unloaded and there is really no way to stop that. I can think of two options:
- Don't show the error if the page is unloading (detected by the
window.onbeforeunloadevent firing). This is OK if you don't really care about the result of the operation, but I do in this case.
- Don't show a visual indication that the vote succeeded until you've received a successful response from the server. That's what I'd like to see implemented.
If you want to get cute about it, you could show some sort of a "vote in progress" indication, like a lighter shade of orange, which turns to the normal orange once a successful response is received.
There are also other times when this would come into play, like when a vote is too old to be changed and a change initially looks like it succeeded, but then you get an error from the server. I think this change would improve that user experience, too.