Try this:
var xmlHttp = new XMLHttpRequest();
var json = {
myJson: localStorage.getItem("sendCart"),
myFormJson: localStorage.getItem("arrayForm")
}
xmlhttp.open("POST", "assets/php/sendToTelegram.php");
xmlhttp.setRequestHeader("Content-Type", "application/json;charset=UTF-8");
xmlhttp.send(JSON.stringify(json));
var json = {
myJson: localStorage.getItem("sendCart"),
myFormJson: localStorage.getItem("arrayForm")
}
Or with the Fetch API:
fetch("assets/php/sendToTelegram.php", {
method: "POST",
headers: {
"Accept": "application/json, text/plain, */*",
"Content-Type": "application/json;charset=UTF-8"
},
body: JSON.stringify(json)
});
The Fetch API is built in, so you don't need any libraries.