when i click the dynamic link, although it call getdetails function but Ajax don't send anything to details.php. That is my problem.

when i click the dynamic link, although it call getdetails function but Ajax don't send anything to details.php. That is my problem.

I take out the link and id from database and create dynamic link, my intention is to grab the link (when people link on) with ajax and send it to php, there php will work the request data with database and return to ajax and my web page will refresh only partly, the following is my code,

when i click the dynamic link, although it call getdetails function but Ajax don't send anything to details.php. That is my problem.

third.php
<?php
$con = mysql_connect("localhost","root","");
$db= mysql_select_db("waifer", $con);
$sql = mysql_query("SELECT * FROM post");
$menu = "";
while($row = mysql_fetch_array($sql)){
$pid = $row['id'];
$link = $row['link'];
$menu .= '<li><a href="third.php?id='.$pid.'" onClick = "getdetails(this.href)">'.$link.'</a></l…
}
?>
<html>
<head>
<script src="http://code.jquery.com/jquery-lates…
<script>
function getdetails(str){
var id = str.replace(/\D/g,'');
$.ajax({
type: "POST",
url: "details.php",
data: {pid:id}
}).done(function( result ) {
$("#msg").html( " Address is "+result );
}); */
}

</script>
</head>
<body>
<div id="bb" ><?php echo $menu; ?></div>
<div id="msg"></div>
</body>
</html>

The folloing is details.php

<?php

$con = mysql_connect("localhost","root","");
$db= mysql_select_db("waifer", $con);

$name = $_POST['pid'];
$pid = preg_replace("/[^\d]/", "", $name);

$sql = mysql_query("SELECT * FROM post WHERE id='$pid'");
while($row=mysql_fetch_array($sql)){
echo $rows = $row['post'];
}
?>