I want to send data post to php site then print. The php print is not working. I already examined the other questions but nothing helpful. It will not work out. Why?
JS (working)
$.ajax({
url: 'https://whatever.com/data.php',
type: 'POST',
dataType: 'json',
contentType: 'application/json',
async: false,
data: data
});
PHP backend (not working)
<?php
header('Access-Control-Allow-Origin: *');
header('Access-Control-Allow-Methods: POST,GET,OPTIONS');
header('Access-Control-Allow-Headers: Origin, X-Requested-With, Content-Type, Accept');
header('Content-type: application/json;charset=utf-8');
$json = file_get_contents('php://input');
$data = json_decode($json);
print_r($data); ?>