jquery version: 3.6.0 php version: 8.1.4
Trying to pass POSt but php gets empty $_POST
index.html
<button onclick="func()">Click me</button>
<script>
function func()
{
var eventID = "test";
$.ajax({
url: "test.php",
method: "POST",
data: {'variable': eventID },
success: function (response) {
console.log(response)
},
error: function(jqXHR, textStatus, errorThrown) {
console.log(textStatus, errorThrown);
}
});
}
</script>
test.php
<?php
if (isset($_POST['variable']))
{
echo($_POST['variable']);
}
else
{
echo ("failure");
}
?>
edit: PHP ReQuest
https://pastebin.com/ASjjxAm1
var_dump
failurearray(0) {
}
I tried every configuration. I think I'm losing my mind