This is probably an annoying rookie-mistake, but I can't find a solution by googling.
I tried sending this post from Visual basics (and from a Javascript-script as well, neither worked)
POST [Deleted the url here]/posttest.php HTTP/1.1
content-type: application/json
{
"name": "sample",
"time": "Wed, 21 Oct 2015 18:27:50 GMT"
}
Also tried this with just "testing" as a body:
var xmlhttp = new XMLHttpRequest();
xmlhttp.onreadystatechange = function () {
if (xmlhttp.readyState === 4 && xmlhttp.status === 200) {
callback(xmlhttp.response);
}
};
xmlhttp.open('POST', 'posttest.php', true);
xmlhttp.send("testing");
My Php-code doesn't echo any body at all, trying all kinds of concepts, all echos are completely empty of text:
<?php
if ($_SERVER["REQUEST_METHOD"] == "POST") {
foreach ($_POST as $key => $value) {
echo $key;
echo $value;
}
echo "raw: " . $HTTP_RAW_POST_DATA;
echo isset($_POST['name']);
echo "post" . implode(", ", $_POST);
$name = $_POST['name'];
if (empty($name)) {
echo "Name is empty";
} else {
echo $name;
}
}
?>
Does anybody find the fault or have any idea how to get the body showing in the post?