retrieving images from server using ajax, jQuery. code not working -


i using following jquery code retrieve images folder on server.

 var dir = "/images"; var fileextension=".jpg";   $.ajax({         url: dir,         success: function (data) {              $(data).find("a:contains(" + fileextension + ")").each(function () {                 var filename = this.href.replace(window.location.host, "").replace("http:///","");                                $("body").append($("<img src=" + dir + filename + "></img>"));             });         }     }); 

i error "failed load resource file:///d:/images" image folder in same path index.html located. idea wrong code. new ajax, appreciated.

you need serve file using web server, example xampp or iis or similar. otherwise code try read directly filesystem , it'll blocked browser.

check url in address bar when load index.html file, start file:///, need set development web server on computer.


Comments

Popular posts from this blog

html - How to style widget with post count different than without post count -

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

javascript - storing input from prompt in array and displaying the array -