Пример кода// script.js
let xhr = new XMLHttpRequest();
xhr.open('POST', '/ajax.php', true);
xhr.setRequestHeader('Content-Type', 'application/json;charset=UTF-8');
let data = {
	id: data_name,
	name: data_name,
	code: data_code,
	value: data_value
};
xhr.send(JSON.stringify(data));
xhr.onload = function () {
	console.log(xhr.response); // Получение ответа
};
Пример кода// ajax.php
<?
$post = json_decode(file_get_contents('php://input'), true);
print_r($post);
?>