check if file exists javascript
function doesFileExist(urlToFile) {
var xhr = new XMLHttpRequest();
xhr.open('HEAD', urlToFile, false);
xhr.send();
if (xhr.status == "404") {
return false;
} else {
return true;
}
}// checking existence of file synchronously
function doesFileExist(urlToFile) {
var xhr = new XMLHttpRequest();
xhr.open('HEAD', urlToFile, false);
xhr.send();
return xhr.status !== 404;
}function executeIfFileExist(src, callback) {
var xhr = new XMLHttpRequest()
xhr.onreadystatechange = function() {
if (this.readyState === this.DONE) {
callback()
}
}
xhr.open('HEAD', src)
}
Also in JavaScript:
- godot get root node
- make welcome message and channel discord.js
- javascript w3schools
- enzynme not support react 17
- square root javascript
- MVC view pass model to javascript function
- dynamic component angular parameters
- how to do a function after a set interval js
- js canvas draw polygon
- jspdf cdn
- d-block d-none js
- javascript array reorder elements
- variable key name js
- Converting from HttpClient to Native HTTP
- javascript boolean
- how to make a css clock
- string to JSONobject android
- Exception in thread "main" org.openqa.selenium.JavascriptException: cannot read getPlayerState
- javascript multiline string
- javascript check if character exists in string
- number is even or odd fucntion in javascript
- redux saga fetch api
- "scripts": { "start": "nodemon index.js", "test": "echo \"Error: no test specified\" && exit 1" },
- loading screen fivem js