问题
As I asked in this meta question: https://meta.stackexchange.com/questions/119259/voting-is-lost-due-to-ajax-call-latency
I wonder about issue, how it occurs?
Is it because browser sends a notification that it says I gave up
or
is it because it is really fast action by user that browser even could not send the xhr
request?
回答1:
I'd guess that the request is sent, but that browsers cancel XHR pending requests when a page is unloaded.
XHR requests can be canceled manually via the .abort()
method, so it wouldn't surprise me if pending requests are aborted.
回答2:
I guess it is because browser was not able to initiate xhr request. Once xhr request get initiated, it doesn't matter whether you are on same page (or) left. There may be sometime consuming calculations before initiating xhr while you click on voting button, if your next action (move to next page or something like that) is that much quicker (where these calculations couldn't complete), your request xhr request might not have initiated.
来源:https://stackoverflow.com/questions/8886099/how-does-ajax-call-terminate-when-window-closed-or-refreshed-too-fast-as-example