How to list filenames from a folder using Jquery and AJAX -


i had googled lot topic , got code solution. when i'm running code in browser error part running , alert being generated. success part never runs.

i'm running code on browser no servers or localhost installed on system.

i had required folders used in code , file.

code follows:

<!doctype html> <html lang="en">     <head>         <title>load demo</title>         <script  src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"> </script>           <script type = "text/javascript" language = "javascript">             $(document).ready(function () {                 var fileextension=".jpg";                 var dir="images/";                 $.ajax({                     type: 'get',                     url: dir,                     async:false,                     success: function (data) {                         $("#filenames").html('<ul>');                         $(data).find("a:contains(" + fileextension + ")").each(function () {                             var filename = this.href.replace(window.location.host, "").replace("http:///","");                              $("#filenames").append( '<li>'+ filename +'</li>');                          });                         $("#filenames").append('</ul>');                     },                      error: function(){                         alert('error loading images');                     }                 });             });         </script>     </head>      <body>         <div id='filenames'>              <h3>showing list of files</h3>         </div>     </body> </html> 


Comments

Popular posts from this blog

php - How to add and update images or image url in Volusion using Volusion API -

javascript - jQuery UI Splitter/Resizable for unlimited amount of columns -

javascript - IE9 error '$'is not defined -