This function executes an AJAX request using the HEAD method allowing us to check whether a file exists in the directory given as an argument. It also enables us to launch a callback for each case (success, failure).
function fileExists(dir, successCallback, errorCallback) {
var xhttp = new XM...