JSFiddle - React, Tailwind, and code Playground
HTML
What need to do?
<input type="text" id="todotext">
<button class="new" onclick="addToDo()">Add to todo-list.</button>
JavaScript
<script>
var addToDo = function () {
var todo = {task: $("#todotext").val()};
var json = JSON.stringify(task);
$.ajax({
type: "POST",
url: "http://localhost:8080/",
data: json,
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (msg) {
console.log(msg);
}
});
}
</script>