If File Exists

by Robert Herring

HTML

<link rel="stylesheet" href="//netdna.bootstrapcdn.com/font-awesome/4.0.1/css/font-awesome.css">
<h1>File Exists</h1>
<div id="check"></div>

CSS

* {
    background: #4679BD;
    color: #ffffff;
}

JavaScript

function checkIndex(file) {
    $.get(file)
        .done(function() {
            // exists code
            $("#check").html('<p><i class="fa fa-check-circle fa-2x"></i> This File Exists</p>');
        }).fail(function() {
            // not exists code
            $("#check").html('<p><i class="fa fa-ban fa-2x"></i> File Does Not Exist</p>');
        });
}


$(document).ready(function() {
    checkIndex('../img/logo.png');
});