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.
1 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');
},
})
-
will this work with relative paths, lets say i just have url: 'abc.html'?– dezmanMay 14, 2013 at 21:31
-
4That answer was given on one of the referenced questions. Why is this different? May 14, 2013 at 21:32
-
-
Refer to this: stackoverflow.com/questions/3646914/… This answer is essentially the same– karthikrMay 14, 2013 at 21:37
-
1
mydomain.com/mypage.html
checking on a file somewhere likesomewhereelse.com/somefile.txt
? Or ismydomain.com/mypage.html
check on a file somewhere likemydomain.com/somefile.txt
?