title: How to handle ajax call when there is no response from the server
body: <p>I have an ajax call for some data (using jQuery). after the user clicks "submit" (and the ajax call has been sent) I am displaying a "Please wait..." message that disables everything until the request returns (so the user won't double click or click other things and mess things up).</p>
  
  <p>It works great when there is any kind of error - the "Please wait..." disappears and I am displaying the user what went wrong.</p>
  
  <p><strong>But what happens if the server don't return me anything back because of communication error?</strong></p>
  
  <p>The solution I found for that is <strong>to set a timeout of 10 seconds for the "Please wait.."</strong> message that after that time it disappears and displays and error that "The communication failed". I assume that if the server didn't respond after 10 seconds then it will not respond at all - but that it false assumption. </p>
  
  <p><strong>The problem is</strong> - how can I be sure that after 20 seconds the server won't return something back? The scenario that might happen is that the user click submits --> 10 seconds later he get an error message --> 5 seconds later server response and confuses the user</p>
  
  <p>How do I make sure that after I hide the "Please wait.." message nothing will pop up from the server? </p>