In a PHP Project I have hyperlink :
<a href="addid.php?id='. $Id . '">| Name |</a>';
When a user click on the link I need to add the selected “id” to session
addid.php Code :
session_start();
$_SESSION['id'] = $_GET['id'];
I need to accomplish this without reloading the page (need to add the “id” to session in background).
How to call addid.php with Javascript & jQuery?
NOTE: I tried this code, but it does load the addid.php in browser
$('a').click(function(){
$.ajax();
return false;
});
Give your link an id:
and then you can easily refer to it:
The code you tried is invalid – have a look at the api for the jquery function you’re using.
urlis a mandatory argument.Check using developer tools/firebug/whatever you have installed that the request is sent to the right place, and the response if what you expect.