title: Checking a Url in Jquery/Javascript
body: <p>All I need is a method that returns true if the Url is responding. Unfortunately, I'm new to jQuery and it's making my attempts at writing that method rather frustrating.</p>
  
  <p>I've seen several examples of jQuery using .ajax, but the code is consistently failing on me. What's wrong?</p>
  
  <pre><code>var urlExists = function(url){
      //When I call the function, code is still executing here.
      $.ajax({
          type: 'HEAD',
          url: url,
          success: function() {
              return true;
          },
          error: function() {
              return false;
          }            
      });
      //But not here...
  }
  </code></pre>