Why jquery with ajax run perfectly on localhost but not while run as local file -


while developing image gallery using javascript,jquery & ajax , code not run in loacally(eg:path:"file:///c:/wamp/www/photogallery/index.html") if run in localhost as(path:"localhost/photogallery/") run , got output.

my officer said there problem code. because jquery run without using localhost.

please me solve problem. please notify mistakes me..

code given below.

1) display images folder (can read images having different names 1.jpg,asd.jpg,ertt.jpg)

var dir=album_name;     var fileextension=".jpg";     $.ajax({         url: dir,         async:false,         success: function (data) {// function read image files             $(data).find("a:contains(" + fileextension + ")").each(function () {                 var filename = this.href.replace(window.location.host, "").replace("http:///photogallery","");                  data1[j++]=dir+filename;             });         }     }); 

2) count no of folder in directory

function countfolder(){ var dir='albums'; var count=12; alert(dir); $.ajax({     url: dir,     async:false,     success: function (data) {         $(data).find("a:contains(" + 'album' + ")").each(function () {// function read foldera name contains 'album'             count++;             //alert(url);         });     } }); return count; 

}

thanks in advance...

value of dir path directory having sub folder. me 'albums'

if run file locally these codes not working.... if localhost work perfectly..

1st code returns path of image files in folder 2nd code returns subfolders count.


Comments

Popular posts from this blog

c# - How Configure Devart dotConnect for SQLite Code First? -

java - Copying object fields -

c++ - Clear the memory after returning a vector in a function -