I am trying to create login page but I stuck on sending data to Cherrypy as a JSON. Trying to override submit button because AJAX does not send any data when I am pressing the button.
Old Code Deleted
@EDIT I have changed the code and now I am not sending any data to server (I assume that cuz there is nothing in console after pressing the button)
My .js
$("#myForm").click(function(){
var dataString = {};
dataString.login = $("#login").val();
dataString.password = $("#password").val();
$.ajax({
type: 'POST',
url: 'http://localhost:8080/login',
data: JSON.stringify(dataString),
contentType: 'application/json',
dataType: 'json',
success: function(response) {
console.log(response);
},
error: function(response) {
console.log(response);
}
});
});
My .html
<!DOCTYPE html>
<html>
<head>
<link href="style.css" rel="stylesheet">
<script src="http://code.jquery.com/jquery-2.0.3.min.js"></script>
<script src="example.js"></script>
</head>
<body>
<div class="login-page">
<div class="form">
<form id="myForm" class="login-form">
<input type="text" name="login" id="login" placeholder="login"/>
<input type="password" name="password" id="password" placeholder="password"/>
<button form="myForm" type="submit">Login</button>
<p class="message">Not registered? <a href="#">Create an account</a></p>
</form>
</div>
</div>
</body>
</html>
Login Page (data not encrypted?)
- Password in the link?
My Console (empty?)
- No Login call
What do I do wrong here?