Created
April 6, 2018 09:01
-
-
Save akira093/a71e0fab7ff0a6bc94ca470624dec457 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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