Created
January 26, 2017 17:44
-
-
Save anonymous/09b78248524e5838e1c75952ff2b44ed to your computer and use it in GitHub Desktop.
JS Bin FormData to json // source http://jsbin.com/jitowa
This file contains hidden or 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
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta name="description" content="FormData to json"> | |
<meta charset="utf-8"> | |
<meta name="viewport" content="width=device-width"> | |
<title>JS Bin</title> | |
</head> | |
<body> | |
<form> | |
<input type="text" value="me" name="username" placeholder="Username"/> | |
<br> | |
<input type="password" value="secret" name="Password" placeholder="Password"/> | |
</form> | |
<script id="jsbin-javascript"> | |
console.clear() | |
var form = document.querySelector("form") | |
var data = new FormData(form); | |
var obj = {}; | |
for (var x of data.entries()) { | |
console.log(x); | |
obj[x[0]] = x[1]; | |
} | |
console.log(obj) | |
console.log(JSON.stringify(obj)) | |
</script> | |
<script id="jsbin-source-javascript" type="text/javascript">console.clear() | |
var form = document.querySelector("form") | |
var data = new FormData(form); | |
var obj = {}; | |
for (var x of data.entries()) { | |
console.log(x); | |
obj[x[0]] = x[1]; | |
} | |
console.log(obj) | |
console.log(JSON.stringify(obj))</script></body> | |
</html> |
This file contains hidden or 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
console.clear() | |
var form = document.querySelector("form") | |
var data = new FormData(form); | |
var obj = {}; | |
for (var x of data.entries()) { | |
console.log(x); | |
obj[x[0]] = x[1]; | |
} | |
console.log(obj) | |
console.log(JSON.stringify(obj)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment