Ryan Ryan - 3 months ago 7x
PHP Question

Trying to capture value of a button and use ajax to submit a query

I have two buttons in a form. The update button updates the data and works fine. I am trying to implement a delete button that will delete the record based on which ever number is echoed in the button attribute value. Right now it is not doing anything.

<form id="update_form" action="" method="post">
<button id="update" type="submit" value="update">Update</button>
<button id="unprocess" type="button" value="'.$order_no.'">DEL</button>

My Jquery

$("#unprocess").click(function (e) {
url: 'unprocess.php',
data: $(this).val(value),
type: 'POST',
success: function (data) {
error: function(data){



My Query:

$order = $_POST['value'];
$sql = "DELETE FROM table WHERE ord_no = $order";
$query = odbc_exec($conn, $sql);

I made the changes on line data:$(this).val(value), now the browser is at least capturing the value of the button, but it is not being passed to the query. any ideas


Try data: { value: $(this).val() } instead of data: $(this).serialize("value")