php - jQuery loading and relative paths -


i'm using jquery load page content so:

$("#content").load(path); 

where content files purely content such:

<!--page.php--> content 

however, when want include images in content this:

<!--page.php--> <img src="images/image.jpg"/> 

the path works relative origin of jquery script instead of page.php file, following example not work code above:

directory tree:  index.php jquery.js pages/   page.php   images/     image.jpg 

because it's making page.php relative jquery is, @ root of site can't find images folder unless give exact path in actual site changes time depending on content file located.

is there non-hacky way around doesn't involve me putting exact path in every image or content want reference?

you can set 1 global variable path of image directory. , use variable path, wherever put images.

if path changes, need change 1 variable value.


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 -