I am trying to get form values with $('#myform').serialize()
but from the alert box it is giving empty Data value, is there any misconfigured I am, my sample code is
<!DOCTYPE html>
<html lang="en">
<head>
<title>Practise</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.16.0/umd/popper.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.min.js"></script>
</head>
<body>
<div class="container">
<h2>Stacked form</h2>
<form id="myform">
<div class="form-group">
<label for="email">Email:</label>
<input type="email" class="form-control" id="email" placeholder="Enter email" name="email">
</div>
<div class="form-group">
<label for="pwd">Password:</label>
<input type="password" class="form-control" id="password" placeholder="Enter password" name="password">
</div>
<div class="form-group form-check">
<label class="form-check-label">
<input class="form-check-input" type="checkbox" name="remember"> Remember me
</label>
</div>
<button type="submit" class="btn btn-primary" id="submit">Submit</button>
</form>
</div>
</body>
<script>
$(document).ready(function () {
$('#submit').click(function () {
var email = $('#email').val();
var pass = $('#password').val();
$.post("save_form.php", $('#myform').serialize(), function(data, status){
alert("Data: " + data + "\nStatus: " + status);
});
});
});
</script>
</html>
Thanks for the help