I have an ajax call for some data (using jQuery). after the user clicks “send” (and the ajax call was sent), I display a “Wait ...” message that disconnects everything until the request returns (so the user will not double-click or click other things and mess things up up).
It works fine when there is some kind of error - “Wait ...” disappears, and I show the user what went wrong.
But what happens if the server does not return anything to me due to a communication error?
The solution I found for this is to set a timeout of 10 seconds for the “Wait ...” message , after which it will disappear and the “Communication error” error message will be displayed. I assume that if the server did not respond after 10 seconds, it will not respond at all, but this is a false assumption.
The problem is how can I be sure that after 20 seconds the server will not return anything? The scenario that can happen is that the user presses the button → 10 seconds later, he receives an error message → 5 seconds later, the server response and confuses the user
How can I make sure that after I hide the message “Wait ...” nothing will come out of the server?
source share