Am passing a variable to JQuery via the data-pid in a href link in payments.php and using AJAX to pass this variable to pmntPopup.php, however the variable is not being passed on
payments.php
<td class="listingTextLeft">
<a href="" data-pid="<?php echo $row[0] ?>" class="pmntDetail"><?php echo $row[20] ?></a>
</td>
<script>
$( ".pmntDetail" ).click(function( paymentID ) {
paymentID.preventDefault();
paymentID.stopPropagation();
var pmntid = $(this).data("pid");
console.log("ID: ", pmntid);
$.ajax({
type: "POST",
url: "pmntPopup.php",
data: {pmntid : pmntid },
success:function(data) {
console.log(pmntid);
$("#pmntDetailPopup").modal({position: ["5%"]});
}
});
});
</script>
The console log in both instances show the correct value for pmntid but when when trying to use POST
to retrieve it in pmntPopup.php below I just get the 'Payment Is Not Carried' message.
pmntPopup.php
<?php
if(isset($_POST['pmntid'])) {
$pmntid = $_POST['pmntid'];
} else {
echo "Payment Is Not Carried";
}
?>
I've searched this site and from what I can tell this should work, I've probably missed something really basic or doing something really stupid ... or both.
Console POST output:
Hi @Jay, have already posted a picture of the POST output from the console above, the picture below shows the Popup window output if that's any help:
As requested the console response output is shown below: