Still don't have a lot of experience with JQuery, but I believe trying to see the post data this way won't work.
This is how I ended up calling the server.
$(document).ready(function(){
$(".add_to_profile").css("background-color", "yellow");
$('a.bookmark').click(function (){
var addedbookmark = function (data) {
var returndata = data;
var nid = returndata.nid;
var divreturn = 'div.return-'+ data.nid;;
var divbookmark = 'div.bookmark-'+ data.nid;
$(divreturn).html(data.nid);
$(divbookmark).html('<a href="remove_bookmark/'+ nid+'" class="remove_bookmark">Remove Bookmark</a>')
}
$.ajax(
{
url : this.href ,
type : 'POST',
contentType : "application/x-www-form-urlencoded",
dataType : 'json',
success : addedbookmark,
data : "js=1"
});
return false;
});
$('a.remove_bookmark').click(function (){
var remove = function (data) {
var returndata = data;
var nid = returndata.nid;
var divreturn = 'div.return-'+ data.nid;;
var divbookmark = 'div.bookmark-'+ data.nid;
$(divreturn).html(data.nid);
$(divbookmark).html('<a href="add_bookmark/'+ nid+'" class="bookmark">Add Bookmark</a>')
}
$.ajax(
{
url : this.href ,
type : 'POST',
dataType : 'json',
success : remove,
data : "js=1"
});
return false;
});
});
and the server function looked like this.
<?php
function add_bookmark ($nid) {
global $user;
if (!$user->uid) {
return 0;
}
$nid = (int)$nid;
if ($nid > 0) {
db_query("insert into {bookmarks} (nid, uid) values (%d, %d)", $nid, $user->uid);
if (isset($_POST['js'])) {
drupal_set_header('Content-type: application/json');
echo json_encode (array(
'success' => 'added to profile',
'nid' => $nid,
));
exit();
}
}
drupal_goto(referer_uri());
}
?>
Hope this helps.