Question: When I run this:

```
<html>
<head>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.js">
</script>
<script type="text/javascript"> 
$(document).ready(function(){ 
    $("#btn").click(function(){
        try {
        $("#div1").load("demoddd.txt"); //there is no demoddd.txt
        }
        catch (err)
        {
            alert("Error: " + err); //this never runs
        }
        finally {
            alert("Finally");
        } 

    });

});
</script></head>
<body>
<button id="btn">Load file</button>
<div id="div1"></div>
</body>
</html>

```

I get "Finally" but no error. In the debug console, I see the 404. Can I trap 404 errors when using the load() function?

Answer: 
Use the `complete` function as shown in the [**documentation**](http://api.jquery.com/load/):

```
$( "#success" ).load( "/not-here.php", function( response, status, xhr ) {
  if ( status == "error" ) {
    var msg = "Sorry but there was an error: ";
    $( "#error" ).html( msg + xhr.status + " " + xhr.statusText );
  }
});

```
You need to get the httprequest status, you can't catch an 404 with that catch.

Use this:

```
$("#div1").load("/demoddd.txt", function(responseText, statusText, xhr){
                if(statusText == "success")
                   alert("Successfully loaded!");
                if(statusText == "error")
                    alert("An error occurred: " + xhr.status + " - " + xhr.statusText);
        });

```

The first thing I would try is to set the full URL, and not a relative one. See if that works first.