title: How to programmatically parse an undetermined number of json files in a folder with jquery
body: <p>Hi I have the following code that enables to parse a json file and its parameters when selecting an option from a select. The code I report here as an example performs the loop on 2 single files.</p>
  
  <p>Since there may be different json files in the folder how can I create a function to pass all the files present in that folder programmatically? I am looking for something that say "until you find any json file, then start the parsing on each one".</p>
  
  <pre class="lang-js prettyprint-override"><code>$(document).ready(function() {
    $("select.species").change(function() {
  
      var selectedSpecies = $(".species option:selected").val();
  
      if (selectedSpecies) {
        //geojson request
        $.getJSON('resources/prova5.geojson', function(data) {
          $.each(data.features, function(key, val) {
            $.each(val.properties, function(i, j) { //i = properties l = properties value
              if (i == 'Species') {
                j = j.replace(/\s+/g, '');
                species = j.split(",");
              }
            }); //first loop ends
          }); //second loop ends
  
          species.forEach(function(animal) {
            if (animal == selectedSpecies) {
              //if the animal is found set the layer to visible
              prova1.setVisible(true);
            }
          });
        });
        //ends geojson request
  
        //geojson request
        $.getJSON('resources/prova7.geojson', function(data) {
          $.each(data.features, function(key, val) {
            $.each(val.properties, function(i, j) { //i = properties l = properties value
              if (i == 'Species') {
                j = j.replace(/\s+/g, '');
                species = j.split(",");
              }
            }); //first loop ends
          }); //second loop ends
  
          species.forEach(function(animal) {
            if (animal == selectedSpecies) {
              //if the animal is found set the layer to visible
              prova2.setVisible(true);
            }
          });
        });
        //ends geojson request
  
  
  
      }
    });
  
    //clears layers
    $("#clearSpecies").click(function() {
      prova1.setVisible(false);
      prova2.setVisible(false);
    });
  });
  </code></pre>