0

I have an "index.php" page to display all posts from database in a LEFT div as follows:

<div class="col-md-6" id="left">
   <a id="link" href="post.php?id=<?php echo $postid;?>"><?php echo $submsg;?></a>
</div>

Also, I have a RIGHT div on same page to expand post when user click on the post link to "read more, comment, like.." as follows:

<div class="col-md-6" id="right">

</div>

And I have a "post.php" page to load it into the RIGHT div..

And I have this Jquery script:

<script>
    $("a#link").click(function(e){
        e.preventDefault();
        $('#right').load(this.getAttribute('href'));
    });
</script>

Everything is fine but there's only one problem which is the href of the page is always "index.php" and I want it to changes into the post link when It display in the RIGHT div.

How can I do it?

Thanks in advance.

Eminos7
  • 1
  • 3
  • May I ask what would be the purpose of changing the url? Is it possible to change the displayed post by entering a different id in the url? – El_Vanja Apr 03 '20 at 15:51
  • 1- The first purpose is to let user share the post which he want to share. 2- And "changing the displayed post by entering a different id in the url" is the 2nd purpose. – Eminos7 Apr 03 '20 at 16:16
  • 1
    Does this answer your question? [How do I modify the URL without reloading the page?](https://stackoverflow.com/questions/824349/how-do-i-modify-the-url-without-reloading-the-page) – El_Vanja Apr 03 '20 at 16:22

0 Answers0