title: Set timeout for ajax (jQuery)
body: <pre><code>$.ajax({
      url: "test.html",
      error: function(){
          //do something
      },
      success: function(){
          //do something
      }
  });
  </code></pre>
  
  <p>Sometimes <code>success</code> function works good, sometimes not. </p>
  
  <p>How do I set timeout for this ajax request? In example, 3 seconds, if time is out, then show an error. </p>
  
  <p>The problem is, ajax request freezes the block until finishes. If server is down for a little time, it will never end.</p>