dimanche 28 décembre 2014

Loading json and images situated outside root directory


I'm trying to load a json file and some images which are situated in some other directory before my root directory. I am now trying this code to get it. It's working fine, but as it seems it's not the perfect way to do it.



$.getJSON("http://localhost/folder1/folder2/folder3/content/LB/contents/content.json", function(json){
console.log(json);
}


and images



<img src="http://localhost/folder1/folder2/folder3/content/LB/contents/locations/locationname/thumbnail.png />


I'm trying to load the json and images to



http://localhost/folder1/folder2/folder3/content/LB/appdrive/html/someHTML.html
http://localhost/folder1/folder2/folder3/content/LB/appdrive/html/js/someJS.js


I'm using only HTML, CSS and JAVASCRIPT. So the main question is is there any way to change the source of json and images to something like this



$.getJSON("folder2/folder3/content/LB/contents/content.json", function(json){
console.log(json);
}


and image



<img src="../folder2/folder3/content/LB/contents/locations/locationname/thumbnail.png />


And one more thing to say, FOLDER2 is the root directory.





Aucun commentaire:

Enregistrer un commentaire