Long time lurker here.
DISCLAIMER:
First of all-, sorry in advance for asking what's probably a duplicate question in this forum. Since I have no experience with ajax I need to be specific about what I'm trying to achieve.
CONTEXT:
I'm working on a social site for me and my friends to use, and I'm in the process of making a simple personal message system. I'm therefore passing parameters in the url by clicking anchors in order to sort out what messages are being displayed to the user etc.
The page itself is called messages.php and it looks like this: [messages.php][1]
As you can see in the picture above, I have a block link called "9 meldinger til" (which translates "9 more messages") at the bottom of the message list. This button counts the remaining PMs for each user and adds two parameters to the url when clicked: ?view=inbox&show_all.
<a href='?view=inbox&show_all' class='small'>" . $remaining . "</a>
These parameters are fetched using $_GET in php:
$view = $_GET['view'];
$show_all = $_GET['show_all'];
When I scroll down on messages.php and click "9 meldinger til", the page (obviously) refreshes and jumps back to the top, now having added the parameters to the url.
WHAT I NEED HELP WITH:
How do I use ajax to stop the page from refreshing after having clicked the anchor? (So that the page doesn't jump around while navigating messages)
And-, how do I implement it on my page? What would an example code look like?