im kinda new to javascript i mean i know the syntax but not so much the libraries.
i need some help to get some files (pictures) from a folder into an arry lets say:
var[] pictures = ?;
(the folder is in my project and contain some pictures)
so i can loop over them and diplay them on the page i did some search but i didnt find any guide on how to do this.
i realy want to understand on how to do this for future projects even a link to known guid you guys know we will be a big help.
if it help im using asp.net.
Well, there are a lot of ways to approach the problem, to me what you can do is (if you don’t know the location of the images beforehand) make a service that returns the src of every image, store that in an array, and then show them in the page.
I believe you are using jQuery so you can make an ajax request like this:
then, from asp, make a new service (
Service.asmxin my case) and create a method that returns the location of the pictures (in my case the method is calledgetSources)I recommend you use JSON (and jQuery.getJSON() method) so you can return a
List<string>.Lastly you can iterate or store the sources in an array, I’ll put an example with the
getJSONmethodonce you have the sources you can display them like this fiddle
Tell me if it helped or if you need another solution.