- Joined
- Apr 28, 2022
- Messages
- 2
- Reaction score
- 0
index.html file placed in a folder and same folder has save.json file. Im running sublime text with server extension.
Console Error: save.json 404 not found.
It can read from the same file but 404 when trying to write !
Console Error: save.json 404 not found.
It can read from the same file but 404 when trying to write !
HTML:
<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.0/jquery.min.js"></script>
</head>
<body>
<div id="hide" style="display:none;">
<p id="title">111</p>
<p id="body">222</p>
<p id="userid">333</p>
</div>
<script>
var OBJ = {
title: document.getElementById("title").innerHTML,
body: document.getElementById("body").innerHTML,
userId: document.getElementById("userid").innerHTML,
};
fetch('/save.json', {
method: 'POST',
body: JSON.stringify(OBJ),
headers: {
'Content-type': 'application/json; charset=UTF-8',
},
})
.then((response) => response.json())
.then((json) => console.log(json));
</script>
</body>
</html>