title: How to handle error In $.get()
body: <p>I have a jquery code in which I am using get() and calling some remote url/file. 
  Now I want to know what the best way is to handle errors from this.</p>
  
  <p>What I am doing is:</p>
  
  <pre><code>   $(document).ready(function() {
          $.ajaxSetup({
              error: function(x, e) {
  
                  if (x.status == 0) {
                      alert(' Check Your Network.');
                  } 
                     else if (x.status == 404) {
                  alert('Requested URL not found.');
  
                  } else if (x.status == 500) {
                      alert('Internel Server Error.');
                  }  else {
                      alert('Unknow Error.\n' + x.responseText);
                  }
              }
          });
  
          $.get("HTMLPage.htm", function(data) {
              alert(data);
              $('#mydiv').html(data);
  
          });
      });
  </code></pre>
  
  <p>This is working fine.But want to know is there any better way of doing this?</p>
  
  <p>ref:<a href="http://www.maheshchari.com/jquery-ajax-error-handling/" rel="noreferrer">http://www.maheshchari.com/jquery-ajax-error-handling/</a></p>