删除按钮不起作用

here in my book database i included both delete and edit button for each of the rows of the book table.When i click delete button it doesn't go to deleteajax.php i.e.it dosen't delete the row of book.Here i have created 2 files one for books.php and another deleteajax.php.In deletebookajax.php i have included ajax code and jquery script...can u please check where i have come across the error. books.php

<?php
include('assets/page_header.php');
?>

<?php
//error_reporting(0);
include('db/db.php');




$str="select * from books";

$query1=mysql_query($str);
echo($query1);
$q=mysql_num_rows($query1);

//$query2=mysql_query("select status from bookrentalinfo where bookid=$bookid");
//echo $query2;
//$res=mysql_fetch_array($query2);
echo "<table>";
echo "<tr><th>BookID</th><th>Title</th><th>Author</th><th>Publisher</th><th>numcopies</th><th>shelfno</th><th>status</th><th>Action</th></tr>";
while($rows=mysql_fetch_array($query1))
{

echo "<tr>";
echo "<td>".$rows['bookid']."</td>";
echo "<td>".$rows['title']."</td>";
echo "<td>".$rows['author']."</td>";
echo "<td>".$rows['publisher']."</td>";
echo "<td>".$rows['numcopies']."</td>";
echo "<td>".$rows['shelfno']."</td>";
echo "<td>".$rows['status']."</td>";
echo "<td><button class='button1' value='delete' name='delete' onclick='delete()'>delete</button></td>";
echo "<td><a href='edit1form.php?book_id=".$rows['bookid']."'>Edit</a></td>";


//echo "<td><button type='button'>delete</button></td>";
/*if($res['status']=="BORROWED")
{
echo "Sorry You Can't Delete The Book";
}
else
{
echo "The Row Is Deleted";
}*/


echo "</tr>";
}
echo "</table>";
?>
</body>
</html>

deletebookajax.php

    <?php
if(isset($_GET['book_id']))
{
    $bookid = $_GET['book_id'];
}
include('assets/page_header.php');
?>


<input type="hidden" name="bookid" value=<?php if(isset($bookid)) echo $bookid; ?>>
<script>
$(document).ready(function(){

    $(".button1").click(function(e){

    var bookid = $("#bbookid").val();
    var title = $("#btitle").val();
    var author = $("#bauthor").val();
    var publisher = $("#bpublisher").val();
    var numcopies = $("#bnumcopies").val();
    var shelfno= $("#bshelfno").val();
    var status = $("#BooksStatus").val();
    var dataString='bbookid='+bookid+'&btitle='+title+'&bauthor='+author+'&bpublisher='+publisher+'&bnumcopies='+numcopies+'&bshelfno='+shelfno+'&BooksStatus='+status;
    if(author==''||title==''||publisher==''||numcopies==''||shelfno==''||status=='')
        {
        alert("Please Fill All Fields");
        }
        else
        {
        function delete()
        {
            // AJAX Code To Submit Form.
            $.ajax({
            type: "POST",
            url: "db/deletebookajax.php",
            data: dataString,
            cache: false,
            success: function(result){
            alert("submitted"+result);
            $('#display').html(result);
            },
            error: function (xhr, ajaxOptions, thrownError) {
                    alert(xhr.status);
                    alert(thrownError);
            }
            });
        }
        }
        e.preventDefault(); 
        });
        });
        </script>




<?php
include('db.php');

//if(isset($_POST['bookid']))
//
//$bookid=mysql_real_escape_string($_POST['bookid']);
$delete = "delete from books WHERE bookid=$bookid";

$query1=mysql_query($delete);
if($query1)
{
$q=mysql_query("select * from books");
$display="<table>";
$display.="<tr><th>BookID</th><th>Title</th><th>Author</th><th>Publisher</th><th>numcopies</th><th>shelfno</th><th>status</th><th>Action</th></tr>";
while($row=mysql_fetch_array($q))
{
$display.="<tr>";
$display.= "<td>".$row['bookid']."</td>";
$display.= "<td>".$row['title']."</td>";
$display.= "<td>".$row['author']."</td>";
$display.= "<td>".$row['publisher']."</td>";
$display.="<td>".$row['numcopies']."</td>";
$display.="<td>".$row['shelfno']."</td>";
$display.="<td>".$row['status']."</td>";
$display.= "</tr>";
}
$display.="</table>";
}
else
{
$display.= "U can't delete The book";
//echo "nothing";
}
echo $display;
?>
</body>
</html>

You do not need to define a function within the document ready function, it is never being called. You can either define it in the global scope, or simply call the .ajax method directly:

$(document).ready(function(){

    $(".button1").click(function(e){

    var bookid = $("#bbookid").val();
    var title = $("#btitle").val();
    var author = $("#bauthor").val();
    var publisher = $("#bpublisher").val();
    var numcopies = $("#bnumcopies").val();
    var shelfno= $("#bshelfno").val();
    var status = $("#BooksStatus").val();
    var dataString='bbookid='+bookid+'&btitle='+title+'&bauthor='+author+'&bpublisher='+publisher+'&bnumcopies='+numcopies+'&bshelfno='+shelfno+'&BooksStatus='+status;
    if(author==''||title==''||publisher==''||numcopies==''||shelfno==''||status=='')
        {
        alert("Please Fill All Fields");
        }
        else
        {
        //function delete()
        //{
            // AJAX Code To Submit Form.
            $.ajax({
            type: "POST",
            url: "db/deletebookajax.php",
            data: dataString,
            cache: false,
            success: function(result){
            alert("submitted"+result);
            $('#display').html(result);
            },
            error: function (xhr, ajaxOptions, thrownError) {
                    alert(xhr.status);
                    alert(thrownError);
            }
            });
        //}
        }
        e.preventDefault(); 
        });
        });

Declare your function out side of click event and call it something like this:

if(author==''||title==''||publisher==''||numcopies==''||shelfno==''||status==''){
    alert("Please Fill All Fields");
} else {
    delete();    
}


function delete() {
// AJAX Code To Submit Form.
$.ajax({
    type: "POST",
    url: "db/deletebookajax.php",
    data: dataString,
    cache: false,
    success: function(result){
    alert("submitted"+result);
    $('#display').html(result);
    },
    error: function (xhr, ajaxOptions, thrownError) {
            alert(xhr.status);
            alert(thrownError);
    }
});
}