I got the answer from this post [How to send or assign Jquery Variable value to php variable? but somehow my PHP can not get the value passed from Jquery
this is html co
Try this, you need to prevent onclick action to go to the that page.
$(document).ready(function() {
$("a").click(function() {
$.ajax({
type: "POST",
url: "random.php",
data: {"name" : $(this).attr('id')}
}).done(function( msg ) {
alert( "Data Saved: " + msg );
});
return false; // prevent from browsing that page
});
});