UPDATE: Tutorial found at link
You should give a more detailed example of what you want to accomplish. But if I understand correctly, you want to use a value from your JavaScript code in your PHP code?
You should try using POST or GET parameters to pass values into PHP. For PHP to be able to do anything, you will have to load a new page.
Lets say you have list.php serving a list of posts. You want to "like" a post. Your JavaScript is on this page. When you click "like", an AJAX POST is sent to like.php with POST parameter id=123.
In like.php, you get the value from the request (using $_POST['id'] or something more appropriate), do your magic (save to db) and echo some result, json_encode(array('success' => true)) for example.
The JavaScript-code that called like.php can then use it's callback to check if the "like" was a success or not and display feedback. The like.php could be any page, you could use list.php if you'd want. I used like.php for clarity.
If this is not at all what you wanted, please provide more information.