POST值没有传递给PHP删除SQL行

I am trying to post the 'ID' from my html table to delete the row from the SQL database when the delete button is click. So far it would appear the POST is not working but the PHP code is.

Here is the JavaScript code which takes the selected table rows value from the first columns (ID) when I select it, and on pressing the delete button a message box displays the ID (this works fine so it would appear it is reading the value). The next part then displays a message box confirming the delete, which on clicking OK does nothing.

JavaScript

$(function(){

    $("#tblAssets tr").click(function(){
    $(this).addClass('selected').siblings().removeClass('selected');    

    });

    $('#btnDelete').click(function(e){
    var value = $("#tblAssets tr.selected td:first").html();
    alert(value);
        if (confirm("Are you sure you want to delete this asset?")) {
            $.ajax({
                type : "POST",
                url : "inventory_hardware_delete.php",
                data : value;
                success : function() {
                }
            });
        }
    });

});

And here is the PHP code. When I manually adjust $value to equal an ID in my database table it works and deletes the row.

 $value = $_POST['value'];


 $sql = "DELETE FROM [Assets].[dbo].[Hardware] WHERE [ID] = $value";
 $result = sqlsrv_query( $conn, $sql); 

Thanks

this line is wrong

data : value;

Try this

data : {value:value},
                    ^ not semi colon

You are passing value without parameter. Add parameter:

$(function(){

    $("#tblAssets tr").click(function(){
    $(this).addClass('selected').siblings().removeClass('selected');    

    });

    $('#btnDelete').click(function(e){
    var data = {
        "value": $("#tblAssets tr.selected td:first").html();
    };
    if (confirm("Are you sure you want to delete this asset?")) {
            $.ajax({
                type : "POST",
                url : "inventory_hardware_delete.php",
                data : $.param(data);
                success : function() {
                }
            });
        }
    });

});

or your ajax data should be like this:

data: "value="+$("#tblAssets tr.selected td:first").html();

Moreover you cannot use ; here:

data : value;

it should be ,

data : "value"+value,//pass value with the name:ie value=10 . replace the ajax part alone as given below

$.ajax({
            type : "POST",
            url : "inventory_hardware_delete.php",
            data : "value"+value,//
            success : function() {
            }
        });

You didn't create an object and passed the variable on the fly directly.

    var value = $("#tblAssets tr.selected td:first").html();
    //alert(value); 
    if (confirm("Are you sure you want to delete this asset?")) {
           var dataValue = {
                 theValue : value     // You have to create an object here
           };     

     $.ajax({
            type : "POST",
            url : "inventory_hardware_delete.php",
            data : dataValue,      // pass the object here            
            success : function() {
            }
        });
    }

On the server side:

$value = $_POST['theValue'];

Try this one.