Skip to content

Instantly share code, notes, and snippets.

@akira093
Created April 6, 2018 09:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save akira093/a71e0fab7ff0a6bc94ca470624dec457 to your computer and use it in GitHub Desktop.
Save akira093/a71e0fab7ff0a6bc94ca470624dec457 to your computer and use it in GitHub Desktop.
<html>
<head>
<title>
test
</title>
<meta http-equiv="Access-Control-Allow-Origin" content="*">
<meta http-equiv="Access-Control-Allow-Headers" content="*">
<meta http-equiv="Access-Control-Allow-Methods" content="GET">
</head>
<body>
<h1>test</h1>
<form action="http://localhost:8090" method="post" id="login">
<p>
text<input type="text" name="text">
</p>
<p>
checkbox <input type="checkbox" name="checkbox" value="1">
</p>
<p>
checkbox2 <input type="checkbox" name="checkbox" value="2">
</p>
<p>
<button type="submit">login</button>
</p>
</form>
<script type="text/javascript">
document.querySelector("#login").onsubmit = (e) => {
e.preventDefault()
const form_data = new FormData(e.target)
const object = Array.from(form_data).reduce((o, [k, v]) => {o[k] = v; return o}, {})
const json = JSON.stringify(object)
alert("test")
fetch("http://localhost:8090/test",{
method: "POST",
body: json
})
}
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment