<p>I'm using the jquery library to load the content of an html file. Something like this:</p>

<p>$("#Main").load("login.html")</p>

<p>If the file (in this case 'login.html') does not exist, I would like to detect it so that I can redirect the user to an error page for example. Any ideas how I can detect if the file to load exists or not?</p>

You can use the ajaxComplete event, whis gives you access to the xhr object which you can query the status of the request e.g a status of 404 will mean the file does not exist.
More Info in the docs
http://docs.jquery.com/Ajax/ajaxComplete#callback
Test here
http://pastebin.me/48f32a74927bb
e.g
```
```
$("#someDivId").ajaxComplete(function(request, settings){
    if (settings.status===404){
        //redirect here
    }
});
```
```