javascript,ajax,PHP insert onSubmit not working ... POST未设置

I'm trying to insert into my MySQL database with an onSubmit() function... For the main part, my function works. However, it keeps inserting a 1 into my DB where the logbook_id field is (the logbook_id should NOT be a 1 every time). Here's my (relevant) html:

echo '<div class="logbook_box" id="logbook'.$id.'" 
      style="display: block; overflow: hidden;">';
echo '<form action="cgi-bin/read_log.php" method="post"
      onSubmit="return ajaxSubmit(this, ' . $id . ');">' . 

'<input type="hidden" value="'.$id.'" id="id" name="id" />'.
'<input style="float: right; width: 20%" type="submit" value="Mark as Read" />' .
'</form>';

Here's the onSubmit function:

<script type="text/javascript" src="cgi-bin/jquery-2.0.3.js"></script>
<script>
var ajaxSubmit = function(form, id) {
    div = document.getElementById("logbook" + id);
    div.style.display = "none";
        // fetch where we want to submit the form to
        var url = $(form).attr('action');

        var id = $('#id').val();

    // setup the ajax request
    $.ajax({
    url: url,
    data: { id : id },
    dataType: "json",
    success: function() {
        if(rsp.success) {
            alert('Marked as read, thanks!');
            }
    }
    });

     // return false so the form does not actually
     // submit to the page
     return false;
}
</script>

And here's my PHP file:

<?php

include('/var/www/olin2/includes/functions.php');
$con = connect_db();
session_start();

$id = isset($_POST['id']);
$username = $_SESSION['username'];

$query = 'insert into read_logbook(logbook_id, username) 
          values("'.$id.'",     "'.$username.'")';
mysqli_query($con, $query) or die(mysqli_error($con));


?>

So, the <div> disappears like it should when Submit is clicked, which shows that the id is getting passed correctly. The PHP script is called, but it either doesn't input anything into the database, or (even more strangely) it will submit my username and the value 1 into the database if I change the PHP from $_POST to $_GET without changing the method in the form.

I'm new at ajax/javascript, so I'm sure it has something to do with the function, but I'm confused and at a complete loss... Any ideas?

add type option as post to your ajax since you are retriving the value as post...default is get..

 $.ajax({
  url: url,
  data: { id : id },
  type: "POST", //<---here
  ....

and make sure the id of logbook_box is different and not 1 all the time

and change this

$id = isset($_POST['id']);   //this return either true or false. so your $id is either 0 or 1

try this

$id = isset($_POST['id'])?$_POST['id']:""; //or $_POST['id']; 

Try this

include('/var/www/olin2/includes/functions.php');
$con = connect_db();
session_start();

if(isset($_POST['id'])){
$id = $_POST['id'];
$username = $_SESSION['username'];

$query = 'insert into read_logbook(logbook_id, username) 
          values("'.$id.'",     "'.$username.'")';
mysqli_query($con, $query) or die(mysqli_error($con));
}