Answer the question
In order to leave comments, you need to log in
How to add data to db.json using jQuery client side?
So I have a db.json file
{
"tags": [
{
"idTag": 1,
"nameTag": "fun"
}
]
}
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8"/>
<script type="text/javascript" src="jquery-1.7.1.min.js"></script>
<script>
$.ajax({
type: "POST",
url: "http://localhost:3000/tags",
data: {"idTag": 2, "nameTag": "title"}
});
</script>
</head>
<body>
</body>
</html>
Answer the question
In order to leave comments, you need to log in
The error was in this:
it was necessary to write like this:data: {"id": 2, "nameTag": "title"}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question