Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

js check if image url exists

function checkImage(url) {
  var request = new XMLHttpRequest();
  request.open("GET", url, true);
  request.send();
  request.onload = function() {
    status = request.status;
    if (request.status == 200) //if(statusText == OK)
    {
      console.log("image exists");
    } else {
      console.log("image doesn't exist");
    }
  }
}
checkImage("https://picsum.photos/200/300");
Comment

check if image exists on server javascript

function imageExists(image_url){

    var http = new XMLHttpRequest();

    http.open('HEAD', image_url, false);
    http.send();

    return http.status != 404;

}
Comment

js check if image url exists

function checkImage(url) {
  var request = new XMLHttpRequest();
  request.open("GET", url, true);
  request.send();
  request.onload = function() {
    status = request.status;
    if (request.status == 200) //if(statusText == OK)
    {
      console.log("image exists");
    } else {
      console.log("image doesn't exist");
    }
  }
}
checkImage("https://apitest.cargoxrate.com/cache/upload/39908016179913740685.jpg?https://picsum.photos/200/300");
Comment

PREVIOUS NEXT
Code Example
Javascript :: array destructuring 
Javascript :: wavesurf js 
Javascript :: javascript union two sets 
Javascript :: axios npm 
Javascript :: how to get the difference between two arrays in javascript 
Javascript :: wait for loop to finish javascript 
Javascript :: how to mock a library in jest 
Javascript :: angular decorators list 
Javascript :: how to repeat string in javascript 
Javascript :: create multiple images in js 
Javascript :: javascript slice and substring 
Javascript :: in vs of javascript 
Javascript :: typeof in js 
Javascript :: javascript date validation less than today 
Javascript :: css react 
Javascript :: quiz javascript example with array 
Javascript :: django ajax redirect to a view on success 
Javascript :: vue 3 install eslint 
Javascript :: points in three js 
Javascript :: Generate a Random Integer 
Javascript :: append javascript example 
Javascript :: combine 2 "arrays with objects" and remove object duplicates javascript 
Javascript :: how manipulate the multiple input option data in one function in vue js 
Javascript :: how to create two dimensional array in js 
Javascript :: express route parameters 
Javascript :: log error line node.js 
Javascript :: how to subtract time in javascript 
Javascript :: service worker registration 
Javascript :: extract text from a string javascript 
Javascript :: sequelize contains 
ADD CONTENT
Topic
Content
Source link
Name
4+8 =