Skip to content

Instantly share code, notes, and snippets.

@LeanSeverino1022
Last active September 2, 2019 06:25
Show Gist options
  • Save LeanSeverino1022/264811e6a4987e49acc5c19b2ad827a6 to your computer and use it in GitHub Desktop.
Save LeanSeverino1022/264811e6a4987e49acc5c19b2ad827a6 to your computer and use it in GitHub Desktop.
[Serialize form data with jquery] from JS Bin// source http://jsbin.com/zofepa
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
</head>
<body>
<form action="">
<label for="name">Name:</label>
<input type="text" name="name" value="Puyih">
<br>
<label for="age">Age:</label>
<input type="text" name="age">
<script src="https://code.jquery.com/jquery-3.1.0.js"></script>
<input type="submit">
<div class="results">Results:</div>
</form>
<script id="jsbin-javascript">
$('form').submit(function(event) {
event.preventDefault();
var form = $('form').serialize();
console.log(form);
$('.results').append(form);
});
</script>
<script id="jsbin-source-javascript" type="text/javascript">$('form').submit(function(event) {
event.preventDefault();
var form = $('form').serialize();
console.log(form);
$('.results').append(form);
});</script></body>
</html>
$('form').submit(function(event) {
event.preventDefault();
var form = $('form').serialize();
console.log(form);
$('.results').append(form);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment