I know there's been several similar questions here, and I honestly read and tried out all the suggested solutions, but none of them worked for me so far, so I'll be really thankful for any hints.
I'm building a portfolio website where links to all the projects are listed in a div class="projects"
on the left, smth. like that:
<div class="projects">
<ul>
<li class="music" ><a href="project1.html">project1</a></li>
<li class="writing"><a href="project2.html">project2</a></li>
<li class="art"><a href="project3.html">project3</a></li>
</ul>
</div>
<div class="main">
</div>
When a respective link is clicked, the project (which has a separate page and should ideally have a separate URL) should open in a div class="main"
on the right without reloading the whole page.
I've tried it with iframe
, which somewhat worked, but in this case it's impossible to give each project a separate URL which is really important in this case.
I've also tried different variations of this script, but also with no result (either nothing happened or project page opened, but not in the desired div
):
<script>
$(document).ready(function(){
$(function(){
$(".projects li a").click(function(e){
e.preventDefault();
var url = this.href;
$(".main").load(url);
});
});
});
</script>
I've read that this could be done with Ajax, but I'm really new to this and afraid it might be a little too advanced for me.
I'll be really thankful for any advice that will help me learn (I still believe I can get it done eventually!)