title: How to handle "Failed to load resource"
body: <p>I am writing Javascript to know the different sites(dev, staging and prod) are UP or not.
  below is my code.</p>
  <pre><code>function URLStatusCheck(url)
  {
  try {
      $.ajax(url,
      {
          contentType: &quot;application/json; charset=utf-8&quot;,
          dataType: 'jsonp',
          crossDomain: true,
          statusCode: {
              404: function (xhr) {
                   alert(&quot;error 404&quot;);
              },
              200: function (xhr) {
                     alert(&quot;Site is UP&quot;);
                  }
          },
          error: function (jqXHR, textStatus, errorThrown) {
              alert(&quot;error&quot;);
           }
      
          }
      }).fail(function (jqXHR, textStatus, errorThrown) {
          alert(&quot;Fail&quot;);
      });
  } catch (err) { alert(url); }
  }
  </code></pre>
  <p>I have problem with invalid URLs, below error are showing in the browser command for the invalid URLs.</p>
  <blockquote>
  <p>Failed to load resource: the server responded with a status of 404 (Not Found)</p>
  <p>Failed to load resource: net::ERR_NAME_NOT_RESOLVED</p>
  </blockquote>
  <p>and those errors I am not able to catch them in any where (try/catch, error or 404).
  Could some one help me where(method or level) I can handled those errors.</p>
  <p>Thanks,
  KPK</p>