Reputation: 9543
I load a page with jquery like this:
$('#container').load('books/book1/inleiding.php');
However, the images are in, books/book1/images so for inleiding.php it's just images/someImage.jpg
And when i load the page then the link to the image stays the same and therefore doesn't work.
I also tried:
$.get('books/book1/inleiding.php', function(data) {
$('#container').html(data);
alert('Load was performed.');
});
But this has the same problem, is there a easy fix?
Upvotes: 1
Views: 280
Reputation: 5007
images should be linked directly to the url or to the server root.
If the image is in books/book1/images/...
then link it to books/book1/images/...
.
Maybe you can try to change the src with:
$.get('books/book1/inleiding.php', function(data) {
$('#container').html(data);
$('#container img').each(function(){
$(this).attr('src', 'books/book1/'+$(this).attr('src'));
});
//alert('Load was performed.');
});
Upvotes: 2