1$str = <<<MY_MARKER
2<script type="text/javascript">
3 document.write("Hello World!");
4</script>
5MY_MARKER;
6
7echo $str;
1const toSend = {
2 x: 10,
3 y: 12
4 };
5 const jsonString = JSON.stringify(toSend);
6 const xhr = new XMLHttpRequest();
7
8 xhr.open("POST", "file.php");
9 xhr.setRequestHeader("Content-Type", "application/json");
10 xhr.send(jsonString);
11//php:
12$request = file_get_contents("php://input");
13$obj = json_decode($request);
14var_dump($obj);