0


I have load all files from one of my folder into my web page with this question : How to load all the images from one of my folder into my web page, using Jquery/Javascript
I use this explanation to make a select of my files like this :

<select>
<option value="path/to/file1">option1</option>
<option value="path/to/file2">option2</option>
...
</select>

How can I open my files with this select?

Community
  • 1
  • 1
bizard
  • 176
  • 13

1 Answers1

1
<select onchange="open_my_file()" id="ajax_fele">
  <option value="path/to/file1">option1</option>
  <option value="path/to/file2">option2</option>
  ...
</select>

<script>
  function open_my_file(){
  var file_url = $("#ajax_fele").val();
        $.ajax({
            url: file_url,
            type: 'GET',
            success: function (data, textStatus, jqXHR) {
                //data have file content.
            }, error: function (jqXHR, textStatus, errorThrown) {
                //error 
            }
        });
  }
</script>

Just make is simple with ajax call.

Ankit vadariya
  • 1,253
  • 13
  • 14