1

I have some svg files in a directory on my localhost. I want to access all of them and use them to do some stuff. But I cannot access them.

$.ajax({
    url : 'assets/svg/',
    success: function(data) { alert("success"); /* do some stuff */ },
    error : function() { alert("error"); }
});

I always get "error". If I access only one file e.g. 'assets/svg/arrow.svg', it works. But I want all files in the directory.

Other answers on stackoverflow say that it should work like that (e.g. here), but it doesn't.

Community
  • 1
  • 1
cloudy_rowdy
  • 77
  • 1
  • 13
  • Do you have directory indexing enabled? What does your browser show, when you request that URL directly? – CBroe Dec 09 '16 at 15:27
  • what is the exact error? The real one, not the arbitrary string you've replaced it with. You can get the details from your browser network tab, or you can implement the `$.ajax` error callback properly, as per the docs: http://api.jquery.com/jquery.ajax/ and display the output – ADyson Dec 09 '16 at 15:32
  • oh you're right! the error is 404 not found but why ?!?! If I enter a filename manually, like described in my question above ('assets/svg/arrow.svg') it works. – cloudy_rowdy Dec 09 '16 at 16:48

1 Answers1

0

if your application server is Tomcat then you can use direcroty alias. You can define some directory in your machine in server.xml and access to all files in this directory as web web content. See

Community
  • 1
  • 1