0

I need to find all images based on their extensions. (jpg, png, gif... etc) and place those images to be viewed in grid?

SunRhythms
  • 11
  • 6
  • 2
    javascript is client side, so you can't do this without the help of a server side script. Check AJAX to see how this can be doable. – CodeBird Feb 17 '14 at 15:47

2 Answers2

1

You can't do this with javascript alone as it's a client-side language, it doesn't "know" about the server (node.js being an exception to this).

However you can use AJAX to retreive a list of images from a PHP script or a JSP or similar.

You can read up on using PHP to get a list of files here: http://www.php.net/manual/en/function.scandir.php

And using AJAX here: http://www.w3schools.com/ajax/ajax_xmlhttprequest_send.asp

If you use jQuery: https://api.jquery.com/jQuery.get/

Or with JSON too: https://api.jquery.com/jQuery.getJSON/

totallyNotLizards
  • 8,489
  • 9
  • 51
  • 85
0

You can do ajax request to server API, which should return that list for you. Server api can be done using Php, Asp.Net or Node.JS (which is javascript)

Vova Bilyachat
  • 18,765
  • 4
  • 55
  • 80