title: How do I set the minimum duration of an Ajax call?
body: <p>I have a website that makes an ajax call and then loads a gif to show static on a TV. But right now the ajax calls don't take enough time for the effect to really pop. So I was wondering if there is a way to set the minimum time the ajax call will take?</p>
  
  <p>You can see <a href="http://www.uvm.edu/~areid/test/demo.html" rel="nofollow">the website</a> I am trying to make to get a better idea of what I am doing. Try clicking the right picture frame or the phonograph on the table.</p>
  
  <pre><code>    &lt;script type="text/javascript"&gt;
      var minDelay = 1000;
      var start = new Date();
      $.get("form.html", function(result) {
          callback($(result).find("#contact"));
          var end = new Date();
          var timeInMilliseconds = end - start;
          if (timeInMilliseconds  &lt; minDelay) {
              setTimeout(function() { callback(result); }, minDelay - timeInMilliseconds );
          }
          else callback(result);
      });
      $.get("music.html", function(result) {
          callback($(result).find("#music"));
          var end = new Date();
          var timeInMilliseconds = end - start;
          if (timeInMilliseconds  &lt; minDelay) {
              setTimeout(function() { callback(result); }, minDelay - timeInMilliseconds );
          }
          else callback(result);
      });
  
  
      function callback(result) {
          $("#screen").html(result);
      }
  &lt;/script&gt;
  </code></pre>