I'm trying to pass a Jquery variable (items) to a php variable $itemdestination on the same page, when pushing the button .bid, which is a submit button:
<script>
$(".bid").click(function () {
var items = $(this).closest("tr") // Finds the closest row <tr>
.find(".nr") // Gets a descendent with class="nr"
.text(); // Retrieves the text within <td>
var itemdestination = $(this).closest("tr") // Finds the closest row <tr>
.find(".no") // Gets a descendent with class="nr"
.text();
$("#prøve").append(items, itemdestination); // Outputs the answer
$.ajax({
url: 'Jobs.php',
type: 'POST',
data: {items: items}
});
});
</script>
<?php
if (isset($_POST['button_pressed'])) {
$itemdestination = $_POST['items'];
//Email information
$admin_email = "[email protected]";
$email = $userName;
$subject = "Bid registered on your cargo";
$comment = $itemdestination;
echo $admin_email;
echo $comment;
//send email
mail($email, "$subject", $comment, "From:" . $admin_email);
}
?>
<script>
alert("Your bid is registered");
</script>
<?php
}
?>
But nothing is passed with the method i'm using. What am I doing wrong??