'How can I send an array/object to another computer? (Without websockets)
This (preferably) is to be accomplished with HTML, Javascript, JSON, PHP, or any key web development language.
I am trying to create a game in which one user's location is sent to another computer in an array/object format, but I have no idea how to accomplish that.
I am trying to avoid using websockets and built-in libraries.
Solution 1:[1]
try this
index.html
<script>
let position = 454;
let data = new FormData();
data.append( "position", JSON.stringify( position ) );
fetch("./test.php",
{
method: "POST",
body: data
})
.then(response => response.text())
.then(data => console.log(data));
</script>
test.php
<?php
echo "The position is " . $_POST['position'];
?>
run idex.html the output in your console would be like:
The position is 454
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | tenshi |
