Test if a file exists with javascript [duplicate]

This question has already been asked here and here. But I have tried three of the answers with no good luck. I am using a system called Niagara which is acting as a web server, which may be the reason these techniques did not work. Nonetheless, I feel there must be a way to check for the existence of a file, not the existence of a 404 or 200 or 0.

Answers:

Answer

You can use $.ajax

$.ajax({
  url: 'example.com/abc.html', //or your url
  success: function(data){
    alert('exists');
  },
  error: function(data){
    alert('does not exist');
  },
})

Tags

Recent Questions

Top Questions

Home Tags Terms of Service Privacy Policy DMCA Contact Us

©2020 All rights reserved.